I got a little problem with sessions.
I wrote this script:
<?
session_start();
if (session_is_registered("usuario"))
{
session_unset();
session_destroy();
setcookie(session_name(),"",0,"/");
header("Location: $start_page"); //redirect to the same page
}
$page = "
<html>
<head>
</head>
<frameset rows=\"18%,*\" cols=\"*\" framespacing=\"0\" frameborder=\"NO\" border=\"0\">
<frame src=\"menu.php\" name=\"topFrame\" scrolling=\"NO\" noresize >
<frame src=\"sistema.php\" name=\"mainFrame\">
</frameset>
<noframes><body>
Your browser don´t support frames</body></noframes>
</html>
";
print $page; //PRINT THE HTML CODE
?>
the script above writes a frameset to the screen, with the frames menu.php and sistema.php
Well, the menu have a dropdown list to chose the location, and when the user select a location, the session variable 'cod_local' is set to that location.
Notice that everytime I enter the page, my frameset destroy the session, making the user have to re-login after a refresh or after exiting and reentering my page (I want it to be that way).
everything is working fine, but when I use CTRL + N (new window on IE6), a new window pops up, with the user loged out (as I espected). But when the user login on the second window, changes in the location of one window afect the other window, as if both the windows where sharing the same session.
when I use
print session_id();
, both windows prints the same id, so I tryied this
<?
session_id(uniqid(rand())); //Creates a new unique ID
session_start();
if (session_is_registered("usuario"))
{
session_unset();
session_destroy();
setcookie(session_name(),"",0,"/");
header("Location: $start_page"); //redirect to the same page
}
$page = "
<html>
<head>
</head>
<frameset rows=\"18%,*\" cols=\"*\" framespacing=\"0\" frameborder=\"NO\" border=\"0\">
<frame src=\"menu.php\" name=\"topFrame\" scrolling=\"NO\" noresize >
<frame src=\"sistema.php\" name=\"mainFrame\">
</frameset>
<noframes><body>
Your browser don´t support frames</body></noframes>
</html>
";
print $page; //PRINT THE HTML CODE
?>
now, when I make
print session_id();
, the windows now prints different ID´s, BUT THEY ARE STILL SHARING THE SAME SESSION!!!
I´m using PHP 4.3.0 and Apache 1.3.26 on Linux and I´m starting to think it´s a bug. Anyone can help me???
Sorry for the long post.