Writing PHP with 'sessioned' and 'unsessioned' behaviour.

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm writing a PHP program that produces two different kinds of output
depending on whether there is an active session.

I'm looking for a nice bit of code to do the initial checking.

This worked with register_globals=On :

   if ($PHPSESSID) { session_start(); }

but I'd prefer to run with register_globals=Off . Also, doing
session_destroy() didn't seem to unset $PHPSESSID.

I'm currently using 4.2.2, but I'd like to write something that is
compatible with later releases (if at all possible).

Re: Writing PHP with 'sessioned' and 'unsessioned' behaviour.

 .oO(Chris Guest)

Quoted text here. Click to load it

The session-ID can be found in the $_GET or $_COOKIE array.


Site Timeline