Jump to content

Recommended Posts

Hey,

 

My http_referer is coming up blank on my localhost, and from what I've read today it's unreliable, so I'd like to remove it from the site.

 

What I'm trying to achieve is a redirect from my login page, depending on which page the user came from. I.e. there are several processes requiring logins, and I want to return them to where they came from once they logged in.

 

Does anyone know of another way of doing this? Been stuck all day  ???

 

Thanks

Emma

Link to comment
https://forums.phpfreaks.com/topic/47592-alternative-to-http_referer/
Share on other sites

Thanks for this. I'm not familiar with JS, can I just check:

 

1) Re: $_POST["where_they_came_from"]

 

How do I do this bit? Do I have to set a variable on each page and carry it to each new page?

 

2) is the below as good as using window.location?

 

if ($_POST['referer'] == "http://localhost/login.php") {
header("Location: http://localhost/myaccount.php");
exit();

 

3) Also, could you also tell me the significance of "/" versus "\" in javascript? I keep seeing it in my site's code and I'd love to know!

 

Thanks a lot

Emma

 

1. Yes. You could grab the URL and just pass it to each new page with a $_SESSION or $_POST variable.

 

2. Yes. It's the same. I've had problems in the past with using header() and having no clue why it wasn't working. I started using the JS redirect and have never looked back ;]

 

3. I don't understand what you mean with the slashes. You'll have to give me some example code to explain. They could have many different uses (escape characters, regular text, url paths, etc).

The JS Redirect is slower than using the header. As long as you do the page right there is no problem re-directing using the header location.

 

As for passing data from your pages I would session instead of POST, unless you are having them submit it via a form.

 

As for the third I only ever see the "/" used in the definition of the script.

 

As seen in Charlie's code he uses the \ to escape the quotes.

 

Anyhow I would highly suggest using Header over the JSRedirect for speed and efficiency. That and you never know if your users have JS disabled.

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.