-1

Page1.php

<?php 
  session_start();
  $_SESSION['test'] = 'abc';
  echo "the Session are set = ".$_SESSION['test'];
?>

Result: the Session are set = abc

page2.php

<?php 
  session_start();

  if(isset($_SESSION['test'])){
    echo "Session = ";
    echo $_SESSION['test'];
  }else{
    echo "Session are not set";
  }
?>

Result: Session are not set

Anant Kumar Singh
  • 68,309
  • 10
  • 50
  • 94

1 Answers1

-1

On page1.php

<?php 
  session_start();
  $_SESSION['test'] = 'abc';
  header("Location: page2.php");//Well we know that this session here works so lets try redirecting...
?>

On page2.php Please try

<?php 
  if( !session_id() )
  {
    session_start();
    session_regenerate_id(true);
  }    
  if(isset($_SESSION['test'])){
    echo "Session = ";
    echo $_SESSION['test'];
  }else{
    echo "Session are not set";
  }
?>
Praveen Kumar
  • 2,388
  • 1
  • 11
  • 20