Jump to content

Archived

This topic is now archived and is closed to further replies.

essjay_d12

Return to page that user just left

Recommended Posts

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

Share this post


Link to post
Share on other sites
[!--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 way
session_start();
session_destroy();
header("location: //page they just came from");

?>
[/code]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.php

However this variable can be spoofed and some browsers may not send this type of information over.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.