I have PHP code with sessions enabled. Session files are being created in tmp
directory but its empty, that’s why my browser Internet Explorer and Chrome are not able to pick up the session and display it across the pages.
Here is my PHP code.
Page2.
<html>
<body>
<form action="test3.php" method="post">
Username: <br><input type="text" name="username"></br>
<input type="submit" name = 'submit1' value= 'Login'>
</form>
</body>
</html>
Page3.
<?php
session_start();
?>
<html>
<body>
<?php
$username = $_POST['username'];
$_SESSION['username']= $_POST['username'];
echo "<br> Hi $username.</br>";
?>
<form action="test4.php" method="post">
<input type="submit" name = 'submit' value= 'click me'>
</form>
</body>
</html>
Page4.
<?php
session_start();
$username = $_SESSION['username'];
echo "<br> Hi $username.</br>";
?>
Problem solved I had to change session.cookie_path
in php.ini
to /
instead /tmp
.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments