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 = '' ; Quote 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 Quote 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 ? Quote 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 Quote 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 Quote 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(); ? Quote 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 ? Quote 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. Quote 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 Quote 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 Quote Link to comment https://forums.phpfreaks.com/topic/73882-solved-kill-session/#findComment-372819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.