Jump to content

Recommended Posts

here's my sample code :

 

topic_detail.php -> this is like the topic we see in forum, and there's a reply link. This url is saved into session using getThisURL function.

<?php
session_start();
$_SESSION['lastURL'] = getThisURL();
?>
<a href='write_reply.php?id=1'>Write reply</a>

 

write_reply.php -> this will process the reply saved into database etc. and after process, will be redirect into redirect.php

<?php
session_start();
//do processing...
header("Location: redirect.php");
?>

 

redirect.php -> this is the page where will take care all redirection. This url will be taken from the session value.

<?php
session_start();
if( isset($_SESSION['lastURL']) ){
header("Location:" .  $_SESSION['lastURL']);
}
?>

 

With that code, relying on session, will fail if user browse in multiple tabs

thanks

Link to comment
https://forums.phpfreaks.com/topic/129354-url-redirection/#findComment-670617
Share on other sites

why not as soon as the page loads grab the data from the session and store it in another variable on that page then when redirecting back just refernece that variable, i mean who is going to open another tab on your site within the miliseconds it takes to grab that session?

Link to comment
https://forums.phpfreaks.com/topic/129354-url-redirection/#findComment-670639
Share on other sites

why not as soon as the page loads grab the data from the session and store it in another variable on that page then when redirecting back just refernece that variable, i mean who is going to open another tab on your site within the miliseconds it takes to grab that session?

it can't be done because im using session, no passing values. it's no use if i grab the session data, because what will i do with the variable?  except that i pass the value with url or hidden text

 

What browser? Having other tabs open shouldn't matter. I use a redirect script that is similar to what you have here, and it isn't affected by tabbed browsers (FF3, FF3, OPERA, IE7)

could you post your sampe code?

i think it's impossible if the value is not overwritten.

imagine i visit topic_a, the session value will be "topic_a".

and then i open a new tab and visit topic_b, and the session value will be overwritten "topic_b"

and then i reply on topic_a and redirect with value "topic_b"

 

Link to comment
https://forums.phpfreaks.com/topic/129354-url-redirection/#findComment-670641
Share on other sites

i think it can be done if using javascript cookie. but i would like not to depend on javascript, because people may disable javascript

 

On my site, I have a theme switcher that uses a session cookie. I opened my site in two tabs, switched the theme in one tab, went to the other tab, and that tab used the session cookie from the first tab. I tested in FF2, FF3, Opera 9.27, IE7, and Safari 3.1.1 on Windows. I didn't check my Mac or Linux browsers, but you shouldn't have any problems with those either.

 

Please show your getThisURL() function, and more code if possible. The problem you are having is almost certainly a result of your code, and not the normal behavior of session cookies.

Link to comment
https://forums.phpfreaks.com/topic/129354-url-redirection/#findComment-671412
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.