PHP Session Variables are not passed to next page -


i have 2 php pages in same folder. trying set session variable on 1 page (test.php), read value on (test2.php). however, session variable gets lost on second page.

test.php

<?php      session_start();      $_session["test"] = "123hello";     $hello = $_session["test"];     echo "out: $hello";      $sid = session_id();      echo "<br> sid: $sid";      ?> 

test2.php

<?php  session_start();  $hello = "test"; if(isset($_session["test"])) {     $hello = $_session["test"]; } echo "out: $hello";  $sid = session_id();  echo "<br> sid: $sid";  ?> 

first visit test.php, outputs:

out: 123hello

then visit test2.php, outputs:

out: test

which means in test.php, session variable keep value. however, reason gets lost in test2.php.


Comments

Popular posts from this blog

inversion of control - Autofac named registration constructor injection -

verilog - Systemverilog dynamic casting issues -

ios - Change Storyboard View using Seague -