troubleshooting Question

Capturing Referring Page when redirected

Avatar of neilsav
neilsav asked on
12 Comments1 Solution363 ViewsLast Modified:

I need to be able to capture a variable on a redirect

The code works like this:

if user is logged in send user to page review?id=1234 (this works as expected)

other wise they are sent to the login page main.php with the code below:

       header('Location: main.php');

Then on main.php when the user logs in they are returned back to the page that they were previously on based on the

$_SERVER['HTTP_REFERER']  rather than review?id=1234

For some reason because I am using the header function to redirect it doesn't count the page that it was trying to access as the referrer page it counts the page that the user was previously on.

What I need to be able to do is capture the page the user would have accessed if they were logged in so I can redirect them there after they login.  The ID in the URL references a unique product ID that provides information on the product based on that ID.
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 12 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 12 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros