Session variables

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
Arulraj
Forum Newbie
Posts: 10
Joined: Sun Dec 14, 2003 11:41 pm
Location: India

Session variables

Post 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
jaxn
Forum Commoner
Posts: 55
Joined: Fri Jan 16, 2004 1:50 pm
Location: Nashville, TN

Post 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
Post Reply