Jump to content


Photo

Return to page that user just left


  • Please log in to reply
3 replies to this topic

#1 essjay_d12

essjay_d12
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 14 March 2006 - 04:45 PM

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

#2 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 14 March 2006 - 04:54 PM

[!--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) View Post[/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]

<?php
//in a very simple way
session_start();
session_destroy();
header("location: //page they just came from");

?>

call me a safe bet, i'm betting i'm not

#3 essjay_d12

essjay_d12
  • Members
  • PipPipPip
  • Advanced Member
  • 121 posts

Posted 14 March 2006 - 04:57 PM

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.

#4 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 14 March 2006 - 05:53 PM

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users