0

Hi I have a basic session code for testing which I have uploaded to two different servers.

File1 -

<?php
// Start the session
session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
// Set session variables
$_SESSION["favcolor"] = "green";
$_SESSION["favanimal"] = "cat";
echo "Session variables are set.";
?>

</body>
</html>

File2 -

<?php
session_start();
?>
<!DOCTYPE html>
<html>
<body>

<?php
// Echo session variables that were set on previous page
echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";
echo "Favorite animal is " . $_SESSION["favanimal"] . ".";
?>

</body>
</html>

we can access the session information we set on the first page.

Links for Server 1 :

http://thycart.in/adaptyapp/1.php

http://thycart.in/adaptyapp/2.php

Links for Server 2 :(not working)

http://103.231.209.162:60070/1.php

http://103.231.209.162:60070/2.php

PHP Info Server 1: http://thycart.in/adaptyapp/phpinfo.php

PHP Info Server 2: http://103.231.209.162:60070/phpinfo.php

For some reason the session is not working in one server.Please help to find the reason.Thanks

TIGER
  • 2,864
  • 5
  • 35
  • 45
Melvin
  • 383
  • 1
  • 13
  • 40
  • 1
    Please refer to this may solve your query .http://stackoverflow.com/questions/155920/php-session-data-not-being-saved – Akshay Nov 23 '16 at 11:55

1 Answers1

0
<?php
session_start();

?>
<!DOCTYPE html>
<html>
<body>

<?php
// Echo session variables that were set on previous page
 if(isset($_SESSION)) {


 echo "Favorite color is " .$_SESSION["favcolor"] . ".<br>";
 echo "Favorite animal is " .$_SESSION["favanimal"]. ".";
  }

 ?>

 </body>
 </html>