Forum Moderators: coopster

Message Too Old, No Replies

too many session variables.

         

bleak26

4:59 pm on Jan 5, 2006 (gmt 0)

10+ Year Member



what would happen if i created session variables in php 5 and did not destroy them and then many sessions were used in a short period, leaving many varables undestroyed.

what is the recomended methord for destroying a single session.

is there a good methord to release all session variables universally.

coopster

5:28 pm on Jan 5, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Out of the box sessions are text files that are stored on the server's filesystem in the directory specified in your php.ini session directive. So, each time you add a session variable, more text gets added to that related file on your server. When a user logs out of a session it is a good practice to clear it out and destroy.
$_SESSION = array(); 
session_destroy();

bleak26

4:03 pm on Jan 14, 2006 (gmt 0)

10+ Year Member



Please can you tell me will this kill the session value called expanded?
Will it do more or will it do something else?

$_SESSION['expanded'] = array();

coopster

3:07 pm on Jan 16, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



That will set the 'expanded' index of the $_SESSION superglobal array to a blank array. In effect, you haven't really *killed* it but initialized it to a blank value. To get rid of it you can unset() [php.net] it. I would not unset() the $_SESSION superglobal though, to initialize the entire superglobal array use the method I have demonstrated.