Jump to content
Larry Ullman's Book Forums
Sign in to follow this  
David L

Header("Location") Redirects And Browser History Incompatibility Issues

Recommended Posts

Hey everyone,

 

I am running into issues using header("Location: x"), as the history (back/forward) buttons in browsers don't seem to keep track properly of the redirects.

 

It's complicated to put into words, so I made a screencast demonstrating the issue. Watch in full screen mode so you can see what I am doing. http://youtu.be/C2Fzkcp5kME

 

If anybody has a solution, I'd be very grateful.

 

Thanks!

Share this post


Link to post
Share on other sites

Hello David,

 

I'll just say that I'm not entirely keen on embedded videos in forum posts (I prefer no media in the forum) and I don't really like spending 4 minutes watching a video in order to help.

 

That being said, I think this is just a poor use of header(). Loading random.php and then going to another page is just poor design. How about having your page choose a random user ID and create the random link to that user's profile? Then it's a literal link and it should work in the browser's history.

Share this post


Link to post
Share on other sites

Larry, thanks!! I'll implement your suggestion. I didn't do it originally because I wanted to avoid adding an extra mysql query (to grab a random user_id) to every single page load, but I guess its the better way to go.

Share this post


Link to post
Share on other sites

I can appreciate that, and if there were a way to do it without the query, that'd be grand, but I think that approach would still be better than the redirect.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...