-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

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98

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,408
  • 1
  • 12
  • 20