views:

33

answers:

2

Hi,

I have the following identical code on my development and production server. It works on the development end, but not on the production side:

<?php
$s = session_start();
mail('[email protected]', 'Site-test', "s=$s; SESSION=".serialize($_SESSION), "MIME...");

Development server shows:

s=1; SESSION=a:4:{s:20:"user_timezone_region";s:13:"Pacific/Samoa";s:4:"lang";s:1:"1";s:12:"sess_user_id";s:3:"225";s:14:"sess_user_type";s:1:"S";} 

Production server shows:

s=1; SESSION=a:0:{} 

There is something wrong with my PHP settings on the production server which I'm hoping to diagnose. Yes, this is linked to my other two questions recently here and here.

More details:

  • I have cPanel running on this server
  • PHP error_log did NOT report the above to be an error (note that the variable 's' is '1')
  • The differences in phpinfo() for the two is mentioned in the first link
+1  A: 

The session, when first started for a new client, is actually empty. That could mean that on the dev server you see a session of a returning client, while on productive — the session of a first-time client.

Ivan Krechetov
A: 

Why do you test your session in such odd way? Why not to make such a simple script

<? 
session_start(); 
if (!isset($_SESSION['counter'])) $_SESSION['counter']=0;
echo "Page reloaded ".$_SESSION['counter']++." times.<br>
<a href=".$_SERVER['PHP_SELF'].'?'.session_name().'='.session_id().">reload</a>"; 
?>

if it works, your sessions works perfectly, but there is something wrong with passing identifier.
If not... there ought to be some error message.

Col. Shrapnel