essjay_d12 Posted March 14, 2006 Share Posted March 14, 2006 When a user click 'logout' i want it to run a script that clears the session but also in that script i want it to bring them back to the page they clicked the link on, how can I do this in php?Thanks Quote Link to comment https://forums.phpfreaks.com/topic/4949-return-to-page-that-user-just-left/ Share on other sites More sharing options...
lessthanthree Posted March 14, 2006 Share Posted March 14, 2006 [!--quoteo(post=354943:date=Mar 14 2006, 04:45 PM:name=Essjay_d12)--][div class=\'quotetop\']QUOTE(Essjay_d12 @ Mar 14 2006, 04:45 PM) [snapback]354943[/snapback][/div][div class=\'quotemain\'][!--quotec--]When a user click 'logout' i want it to run a script that clears the session but also in that script i want it to bring them back to the page they clicked the link on, how can I do this in php?Thanks[/quote][code]<?php//in a very simple waysession_start();session_destroy();header("location: //page they just came from");?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/4949-return-to-page-that-user-just-left/#findComment-17419 Share on other sites More sharing options...
essjay_d12 Posted March 14, 2006 Author Share Posted March 14, 2006 yes but how would i dynamically know where they just came from - as logout option which runs this script will appear on many different locations. Quote Link to comment https://forums.phpfreaks.com/topic/4949-return-to-page-that-user-just-left/#findComment-17420 Share on other sites More sharing options...
wildteen88 Posted March 14, 2006 Share Posted March 14, 2006 Just use $_SERVER['HTTP_REFERER'] this should hold the full url to the page the user used in in order to get to your logout page. So if you clicked a link in a page called page1.php in mydomain.com/folder1/page1.php then it should return mydomain.com/folder1/page1.phpHowever this variable can be spoofed and some browsers may not send this type of information over. Quote Link to comment https://forums.phpfreaks.com/topic/4949-return-to-page-that-user-just-left/#findComment-17441 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.