sfx81 Posted June 29, 2008 Share Posted June 29, 2008 Hi, I got a page name in referrer variable, and by echoing it, it shows correct page, but I cant redirect it to to that page. I tried like this ... echo $_SESSION['referrer']; header('refresh:2; url = $_SESSION['referrer'] '); result: Parse error: syntax error, unexpected T_STRING in C:\wamp\www\test\signup.php on line 28 and then something like this. echo $_SESSION['referrer']; header('refresh:2; url = $_SESSION[\'referrer\'] '); result: (Rather than taking value from variable, its redirecting to "$_SESSION['referrer'] page.) http://localhost/test/$_SESSION['referrer'] Any idea whats going wrong ? Link to comment https://forums.phpfreaks.com/topic/112489-redirect-using-session/ Share on other sites More sharing options...
MasterACE14 Posted June 29, 2008 Share Posted June 29, 2008 <?php $url = $_SESSION['referrer']; header('Location: $url'); if you want to put a delay on it use sleep() around header(). ACE Link to comment https://forums.phpfreaks.com/topic/112489-redirect-using-session/#findComment-577570 Share on other sites More sharing options...
sfx81 Posted June 29, 2008 Author Share Posted June 29, 2008 Hi, tried this <?php $url = $_SESSION['referrer']; header('Location: $url'); ?> but this is giving up HTTP 404 error (page not found) however strangly enough, if I try to go back via putting the url as link on page it works echo "<a href = \"$url\"> Back </a>"; Link to comment https://forums.phpfreaks.com/topic/112489-redirect-using-session/#findComment-577648 Share on other sites More sharing options...
Nexy Posted June 30, 2008 Share Posted June 30, 2008 What is the code where your storing the $_SESSION? This should work: header("location: $_SESSION['referrer']"); Well, does for me. Link to comment https://forums.phpfreaks.com/topic/112489-redirect-using-session/#findComment-577744 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.