Why do my session variables not work in PHP?

  • Thread starter Thread starter Devil's Incarnation...
  • Start date Start date
D

Devil's Incarnation...

Guest
I am able to start a session (based on the cookie I get in the web browser but it does not seem to propagate from one page to another. Then I tried to do it in the same page without any luck :(

Please advice.

----------------------------------------------------------------

<?php
session_start();
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+ 1;
else
$_SESSION['views'] = 1;

echo "views = ". $_SESSION['views'];
?>

-------------------------------------

Output: views = 1 (Although I refreshed the page many times).
 
Weird, it worked perfectly for me :|
Run this code, and see if any errors pop up.
<?php
error_reporting(E_ALL);
session_start();
if(isset($_SESSION['views']))
$_SESSION['views'] = $_SESSION['views']+ 1;
else
$_SESSION['views'] = 1;

echo "views = ". $_SESSION['views'];
?>
 
Back
Top