Jump to content

Something to do with redirect I think ...


stuart.cole

Recommended Posts

Hi, I have a nice little log in script for members of my site, and I can redirect on successful login to a specific page, but I am struggling to know what to do to get them back to the page they logged in from.

 

To be more specific - the site uses multiple session variables to generage certain pages, just using

if($retval){
         header("Location: ".$session->referrer);
      

ends with the right page, but without the session variables so therefore a problem.

 

If I let this page load and then backpage it works fine as it is going to the previously loaded page with the variables intact.

 

Simply put - is there a way to automate the process of forcing a backpage once another page has loaded?

 

Thanks

Stu

Link to comment
Share on other sites

Do you do all your login on one page or you have a login form which (ie login.php) that submits to the processing page (process.php)?

 

Dependant on how you are doing things another way is to have a hidden input like this

echo '<input type="hidden" name="redirect" value="'.$SERVER['PHP_SELF'].'" />';

 

You can then do something like

if(isset($_POST['redirect'])){
header('Location: '.$redirect);
}else{
//Send them to a login success page or index.php
}

Link to comment
Share on other sites

My pages are made up from multiple php files (have a look at http://www.moneysavingdeals.co.uk ) and the pages are made from the header, points file, login file, left, centre, right and footer.

 

On the login part, the call is to process.php to action the logging in/out/changes etc and as each action happens it changes it's headers to redirect on completion of the action which works very well. To save members going through the process of finding the site they want cashback from again it would be ideal to reload the originating page - which works, mostly. The issue is it doesn't have the session information as it's been through process.php so calls for merchant ID and Category ID fail and it returns a blank page.

 

I could write the session info calls into process.php into it but it would be a pain as this file has shown itelf to be quite fragile in the last - getting it to finish process.php and change it's header to 'back page' would be an easy answer as once logged in you would return to the previous page still logged in and able to do what was wanted from there, but I don't know if it's possible.

 

Does this make sense?

 

So the question I suppose is - can you do a header redirect to go back 1 page or not?

Link to comment
Share on other sites

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.