Jump to content

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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.