SESSIONS and back and forth between pages
Posted: Thu Apr 02, 2009 2:11 am
Hi
I am a Newbie to php and I am running into a bit of a problem with sessions staying set when going to and from pages
i made a simple site with 3 pages (code bellow)
i enter text in isset.html and it is saved in the session['fred'] to isset1.php, it is also saved when go to isset2.php, but when i click to go back to isset1.php the session is blank. it is also blank if i click the "log out" button on isset1.php
any clues on how to get the session to stay, or should i use a cookie instead?
any help would be great!
Thanks in advance
Oliver
isset.html
isset1.php
isset2.php
I am a Newbie to php and I am running into a bit of a problem with sessions staying set when going to and from pages
i made a simple site with 3 pages (code bellow)
i enter text in isset.html and it is saved in the session['fred'] to isset1.php, it is also saved when go to isset2.php, but when i click to go back to isset1.php the session is blank. it is also blank if i click the "log out" button on isset1.php
any clues on how to get the session to stay, or should i use a cookie instead?
any help would be great!
Thanks in advance
Oliver
isset.html
Code: Select all
<html>
<body>
<form action="isset1.php" method="post">
user name<input type="text" name="fred"/>
<input type='submit' value='GO!!'/>
</form>
</body>
</html>Code: Select all
<?
SESSION_START();
$_SESSION['fred'];
?>
<table width="100%" border="1">
<tr>
<td colspan="3"><center><font size="+3" color="#5670F6">INKY</font></center></td>
</tr>
<tr>
<td width="15%" >
<a href="http://localhost/isset.html">ISSET.HTML</a><br>
<a href="http://localhost/isset1.PHP">ISSET1.PHP</a><br>
<a href="http://localhost/isset2.PHP">ISSET2.PHP</a>
</td>
<td width="85%" >
<? $_SESSION['fred']=$_POST['fred'];
IF(ISSET($_SESSION['fred'])){
echo"<h1> IT'S SET</h1>";
}ELSE{
echo"<h1> IT'S NOT SET</h1>";
}
echo $_SESSION['fred']; ?>
<form action="isset1.php" method="post">
<input type='submit' value='log out' name="log"/>
</form>
</td>
</tr>
</table>Code: Select all
<?
SESSION_START();
$_SESSION['fred'];
?>
<table width="100%" border="1">
<tr>
<td colspan="3"><center><font size="+3" color="#5670F6">INKY</font></center></td>
</tr>
<tr>
<td width="15%" >
<a href="http://localhost/isset.html">ISSET.HTML</a><br>
<a href="http://localhost/isset1.PHP">ISSET1.PHP</a><br>
<a href="http://localhost/isset2.PHP">ISSET2.PHP</a>
</td>
<td width="85%" >
<?echo $_SESSION['fred'] . "<br>";
echo"fred<br>";?>
</td>
</tr>
</table>