SirChick Posted October 18, 2007 Share Posted October 18, 2007 Is there a set way to kill the session (like when a user logs out) or do you just set session = '' ; Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/ Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Share Posted October 18, 2007 Do: unset($_SESSION['SESSION_NAME']); OR To unset all $_SESSION vars: $_SESSION = array(); READ the PHP manual http://php.net/ They have all your answers Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372804 Share on other sites More sharing options...
SirChick Posted October 18, 2007 Author Share Posted October 18, 2007 $_SESSION = array(); < would that kill all sessions relating to that user? Or all users ? Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372807 Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Share Posted October 18, 2007 ^ Sessions are run on a per-computer basis... so killing all the sessions, would only kill the sessions on the user (their computer) that logged out everyone's sessions are seperate Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372808 Share on other sites More sharing options...
MadTechie Posted October 18, 2007 Share Posted October 18, 2007 http://uk3.php.net/manual/en/ref.session.php Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372810 Share on other sites More sharing options...
marcus Posted October 18, 2007 Share Posted October 18, 2007 Can't we just use session_destroy(); ? Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372811 Share on other sites More sharing options...
SirChick Posted October 18, 2007 Author Share Posted October 18, 2007 unset($_SESSION['SESSION_NAME']); session_destroy(); If these 2 do the same what would be the better choice this is one of php's most confusing aspects theres more than one option for the same thing =/ there must be reasons ? Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372814 Share on other sites More sharing options...
marcus Posted October 18, 2007 Share Posted October 18, 2007 unset specifically kills the defined parameter, session destory destroys the whole session. Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372815 Share on other sites More sharing options...
Wes1890 Posted October 18, 2007 Share Posted October 18, 2007 And if that was confusing ^ above.. here is an explanation Lets say you have 3 sessions variables (right....) $_SESSION['username']; $_SESSION['password']; $_SESSION['logged_in']; If you want to remove 1 of the sessions, then do this: unset($_SESSION['username']); If you want to remove all of them (all 3 in this example), then do this: session_destroy(); There ya go Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372816 Share on other sites More sharing options...
SirChick Posted October 18, 2007 Author Share Posted October 18, 2007 thankyou all Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372819 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.