Page 1 of 1

Session variables

Posted: Wed Jan 28, 2004 1:29 am
by Arulraj
Hello,

I want to use session variables to check the user is coming from the main URL. Even if the user gives the subsequent htm/php page, the browser should redirect to the initial page (main URL).

I am starting the session with session_start();
please tell me how to register the session_register($id) and keep a track of this till the user exit from the application.

Is it advisable to store this data in the database?

Thanks in advance

S.Arul

Posted: Wed Jan 28, 2004 11:06 am
by jaxn
You don't need session_register. You just need to set a session variable.

Try putting something like this on every page:

Code: Select all

<?php
session_start();  // line not needed if session_auto_start = 1 in php.ini
if (!isset($_SESSION['entryURL'])) {
    $_SESSION['entryURL'] = $_SERVER['REQUEST_URI'];
}
?>
Then you can always access $_SERVER['entryURL'] to know the first page they saw this session.

-Jackson