Page 1 of 1

redirecting to previous page after registering session value

Posted: Wed Sep 22, 2004 3:07 am
by fadi
Hi All!
i want to know any method of how can i redirect to previous page from where i logged on after registering sessions variables..so use doesnt have to navigate throughout the sitemap.
infact i've many pages of login option..i just want that user just puts his user id pwd and registers it in session and redirects to the previous page..how can i accomplish that ? are session variables capable enough for this purpose ?
regards..

Posted: Wed Sep 22, 2004 4:43 am
by Harlequin
Fadi

If all you want to do is send someone back to the page they were on whilst ensuring the session variables are logged you could simply give them a back button.

If you want to do this automatically, which I suspect would irritate the hell out of your users you could force a refresh and use client side script to send them back.

I'd recommend a back button though as forcing a refresh and back will be very annoying for your users.

submit to itself

Posted: Wed Sep 22, 2004 5:19 am
by phpScott
Why not just have the page submit to itself and have the page determine which login option to use.
It would save have to use back buttons, header redirection and the like.

Posted: Wed Sep 22, 2004 10:14 am
by Breckenridge
if you must; use a header() and pass the session_id
i.e.

Code: Select all

<?
header ("location: http://domain.com/page.php?PHPSSID=$YOU ... D_VAR_HERE");
?>

Posted: Wed Sep 22, 2004 10:26 am
by Joe
Or you could redirect to the previous page by using something like:

untested:

Code: Select all

<?php
print("<meta http-equiv=refresh content='1; url=http://www.yoursite.com/.".$_SERVER['HTTP_REFERER']."'>");
?>

Posted: Wed Sep 22, 2004 11:10 am
by feyd
note: do not bank on HTTP_REFERER existing... ;)