Session Error

Report any found bug here. We are grateful for any useful clues.

Moderator: severin

Post Reply
hakkakarda
Posts: 1
Joined: Tue 8. Oct 2013, 19:35

Session Error

Post by hakkakarda » Tue 8. Oct 2013, 19:45

I installed MAMP and everything work for a few months. But now, $_SESSION doesn' t work. When I try to create a session on a login page, it can create session but, when I redirect another page, session lost. It was working until a few days ago, I didn't change anything. Please help me.

A sample:

loginTest.php
######################
<?php
if($_POST){
echo "Login";
$username=strip_tags($_POST['un']);
$_SESSION['testUser']=$username;
// echo $_SESSION['testUser']; // if I delete // from beginning of this line and add it to the following line, session will be printed to the screen.
echo "<script>window.location.href=('loginRedirect.php')</script>";
}else{
?>
<p>Login</p>
<form method="post">
<p>un . <input type="text" name="un" /></p>
<p>pw . <input type="password" name="pw" /></p>
<p><input type="submit" value=" Submit ">
</form>
<?php
}
?>
#################

loginRedirect.php
#################
<?php
if(isset($_SESSION['testUser'])){
echo $_SESSION['testUser'];
}else{
echo "<script>window.location.href=('loginTest.php')</script>";
}
?>
##################

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest