[SOLVED] PHP5 + header() call looses session settings

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
drew
Forum Members
Forum Members
Posts: 72
Joined: Wed Jan 02, 2008 5:37 pm

[SOLVED] PHP5 + header() call looses session settings

Post by drew »

Hello and please excuse me for reposting here.

In the http://forum.cmsmadesimple.org/index.php/topic,18525.msg93994.html#msg93994 thread, I've been trying to get 1.2.3 installed on my hosting system which is running PHP 5.2.5 and Apache with Server API: CGI (phpSUEXEC).

My problem is with the CMSMS install script where it fails to see the session save_path setting. Specifically, www/index.php does see the save_path but www/install/index.php does not.

I have successfully installed CMSMS on several single hosting systems, but this problem seesm to be related to my hoster's systems configuration - which is running SUEXEC for each hosted website.

I have been able to track down the failure to lost session data after the header() call within redirect() of misc.functions.php

I have created simple scripts to reproduce the problem:

Code: Select all

<?php
# t1.php   similar to .../public_html/index.php

$dirname = dirname(__FILE__);
session_start();
$_SESSION['foo'] = "bar";

/*
$sesfile = session_save_path();
if(is_writable($sesfile))
die ("t1: session file '$sesfile' is writeable"); // always TRUE, works just fine
else
die ("t1: session file '$sesfile' is not writeable");
*/

require_once($dirname.'/lib/misc.functions.php'); // pickup the 'redirect()' method

redirect('install/t2.php');
?>

Code: Select all

<?php
# t2.php      similar to .../public_html/install/index.php

session_start(); // added this call to make 'foo' work
echo $_SESSION['foo'];

$sesfile = session_save_path();
if(is_writable($sesfile))
die ("<p>t2: session file '$sesfile' is writeable");
else
die ("<p>t2: session file '$sesfile' is not writeable"); // always TRUE !
?>
Notice that 'foo' is reported properly, but save_path is NOT. This all seems related to passed session info between scripts.

I'm no PHP guru and having spent a week trying to resolve this, I was hoping for some new suggestions. Other proposed solution from the web have not worked.

And since redirect() is used by many other CMSMS scripts, I'm afraid that other modules may not function properly.

Thank you for all suggestions.

-Drew
Last edited by drew on Wed Feb 06, 2008 7:14 pm, edited 1 time in total.
Pierre M.

Re: SUEXEC + header() call looses session settings

Post by Pierre M. »

Hello again,

I'm not a coder hence no PHP guru. If I understand well the PHP layer has a problem. What about talking with your hosting provider about it ?

Pierre M.
drew
Forum Members
Forum Members
Posts: 72
Joined: Wed Jan 02, 2008 5:37 pm

Re: SUEXEC + header() call looses session settings

Post by drew »

Hello Pierre,

I was thinking of doing that but I haven't convinced myself that cmsms is stable under PHP 5.2.5 on anyone's system.

I saw in another thread the question of PHP 5.2 support which caused me to look at the doc wiki where the system requirements show PHP 4.3+  Would this mean that cmsms has not been qualified to run under the newer PHP 5.x +

-Drew
Pierre M.

Re: SUEXEC + header() call looses session settings

Post by Pierre M. »

But your "simple scripts to reproduce the problem" are not CMSms and demonstrate a PHP layer issue, don't they ?

Pierre M. (still not PHP reader)
drew
Forum Members
Forum Members
Posts: 72
Joined: Wed Jan 02, 2008 5:37 pm

Re: SUEXEC + header() call looses session settings

Post by drew »

True, they are not cmsms but each is based on actual cmsms index.php install scripts. t1.php actually calls 'redirect()' which is a cmsms script.

I will try to replacing redirect with a simple header() call which should redirect to t2.php, just like redirect() does. If this shows a failure, then the the problem would indeed NOT be related to cmsms.

Thank for joggling my brain cells.

-Drew
drew
Forum Members
Forum Members
Posts: 72
Joined: Wed Jan 02, 2008 5:37 pm

[SOLVED] PHP5 + header() call looses session settings

Post by drew »

subject renamed from: SUEXEC + header() call looses session settings

After a bit more investigation on the web and at php.net, it became apparent that PHP might still have some issues with session handling, especially across page redirects.

I looked closer at our host PHP configuration and decided to enable FASTCGI mode. This was done thru the hoster web interface. Unsure if there are other ways to do this.

This SOLVED the CMSMS installation issues and problems with test scripts. I'm actually quite surprised that no other CMSMS users have not run across this problem.

It might be helpful to update the CMSMS 'system requirements' - to show validated server configurations. In this case PHP5.2.5 with fastCGI.

Subject has been marked solved. Subject was also corrected to reflect the real problem

Thanks for everyone's help.
Post Reply

Return to “CMSMS Core”