Jump to content

Return to page that user just left


essjay_d12

Recommended Posts

[!--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]
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.

Archived

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

×
×
  • Create New...

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.