I have registered a session in index.php and print it.
$_SESSION['login'] = 'ok'; //print 'ok'
then in page1.php got this session and change it.
<?$_SESSION['login'] = 'no';?>
setTimeout('window.location="index.php"', 100);
Now in index.php there is still print 'ok'. How can?
On each you script, you need to include the following line of code:
<?php session_start(); ?>
If you do not do this, PHP will not persist $_SESSION
vars and it will default to whatever was originally set.
To read more about PHP $_SESSION
variables, take a look here: PHP: session_start()
from your comment, you had session_start()
on both right? but lets take this step by step:
since you dont have any condition whatsoever in index.php, even if you set it on some other page, it will always print 'ok'