View Full Version : On sessions...

03-12-2003, 08:59 PM
The php manual is not too clear on sessions, and after tinkering with it, I still have some questions:
Does a session_start() look for previous sessions on the users computer (ie cookies)?
In order to initialize a session variable (say: $_SESSION["Admin"] = False) each time a user visits a page for the first time, do I have to call session_unset()?
I started a page with session_start(), but echo SID returns an empty string. How comes?

I thought session variables had to be passed on "manually", either via cookies or via the URL. It seems as if PHP decides for itself whether to keep the values inside a session variable.

03-13-2003, 12:37 PM
session_start sort of looks for a client cookie
in reality the client cookie data is sent with the http request for the page - so session_start really only assigns the data to $_SESSION variables ready for the script to access.

check your phpinfo() and find out what the session id name is - it might well be something different to SID (there are numerous variants)

you shouldn't need session_unset - as $_SESSION['admin'] = false; would overwrite any existing value of the session var 'admin'

03-14-2003, 02:24 PM
Aha! Thanks. All has been fixed now