richiec Posted October 17, 2007 Share Posted October 17, 2007 Hey there, i have the login all set up and im trying to add a logout option however its not working lol this is what i have //registers session on login session_register("myusername"); session_register("mypassword"); now on logout.php i would have thought it would be something like... <? session_unregister("myusername"); session_unregister("mypassword"); echo "you are now loged out." ?> It echos the "you are now loged out." but it doesnt actualy log you out. Any ideas of what im doing wrong? Quote Link to comment https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/ Share on other sites More sharing options...
corbin Posted October 17, 2007 Share Posted October 17, 2007 You forgot session_start(); And, as of PHP 4 (I think) session_(un)register() is depricated.... Quote Link to comment https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/#findComment-371955 Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 your probably missing session_start(); Personally..i would do this.. kinda overkill but works.. session_start(); $_SESSION["myusername"] =""; $_SESSION["mypassword"] =""; unset($_SESSION['myusername']); unset($_SESSION['mypassword']); session_destroy(); Quote Link to comment https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/#findComment-371959 Share on other sites More sharing options...
richiec Posted October 17, 2007 Author Share Posted October 17, 2007 You forgot session_start(); And, as of PHP 4 (I think) session_(un)register() is depricated.... yeah i didnt on the logout.php thanks. your probably missing session_start(); Personally..i would do this.. kinda overkill but works.. session_start(); $_SESSION["myusername"] =""; $_SESSION["mypassword"] =""; unset($_SESSION['myusername']); unset($_SESSION['mypassword']); session_destroy(); i tried that and it does log me out now so thanks for that. However it does log me out but it gives me this error Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/www/fearedwarlords.dks-gfx.com/new/login/logout.php:9) in /home/www/fearedwarlords.dks-gfx.com/new/login/logout.php on line 44 you are now loged out. Line 44 is session_start(); any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/#findComment-371962 Share on other sites More sharing options...
MadTechie Posted October 17, 2007 Share Posted October 17, 2007 move session_start(); to the VERY TOP of the page it must be called before anything is sent to the page Quote Link to comment https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/#findComment-371966 Share on other sites More sharing options...
richiec Posted October 17, 2007 Author Share Posted October 17, 2007 Thank you, works perfectly now. Thanks again Rich. Quote Link to comment https://forums.phpfreaks.com/topic/73716-solved-logout-end-session/#findComment-371969 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.