Page 1 of 1

session variable

Posted: Tue Jun 06, 2006 1:55 am
by beckbapegeneral
hi

i need help in sessioning userid. the user is to login and i am to session the userid so that it can be use everywhere in the websites till the user log off. can someone please help

Posted: Tue Jun 06, 2006 2:22 am
by lostinfog
I just use the same solution in my own site.

Before every session superglobal operation, call:
session_start().

When login,

Code: Select all

session_start();
$_SESSION['user_id'] = xxx;
In other pages,

Code: Select all

session_start();
if (isset($_SESSION['user_id'])) {
   ...
} else {
   ...
}
When logout:

Code: Select all

session_start();
unset($_SESSION['user_id']);

Posted: Tue Jun 06, 2006 2:26 am
by beckbapegeneral
thanks alot for the help :D