Forum Moderators: coopster

Message Too Old, No Replies

weird session problem

php session problem

         

masionas

8:46 pm on Jun 7, 2005 (gmt 0)

10+ Year Member



ok, here's the thing. I have two server with almost the same environtment, the only difference is on one apache was built from source and another was rpm.

OS: Fedora Core 3
apache 2.0.54 - from source
apache 2.0.52 - from rpm
php 5.0.4

On one box session is working correctly the files in /var/lib/php/session are not 0 size when they are expected to hold some session data storing from scripts. But this is not case for another box. The actual session files are created but they are not filled with data as it is expected and they are always 0 size and session variables are empty.

The sites on both boxes are the mirrors of each other.
php.ini is identical.
permission on /var/lib/php/session are the same
both httpd are running under apache:apache user group.

Any clues? Thank you for any ideas.

P.S. Forgot to say both boxes are running under SELinux

mcibor

9:22 pm on Jun 7, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you have session_start() on each of them? Is the php code the same? Are the httpd configs the same? Maybe you don't parse certain file types? It's hard for me to say, as I have never had such a problem.

Is the script working the same disregarding the session?

It's not of much help, hope someone will know better.
Best regards
Michal Cibor

masionas

9:36 pm on Jun 7, 2005 (gmt 0)

10+ Year Member



yes, session_start() is called at the top of include file, which is included in ethe scripts we are taking in the cosnideration. All is working on one box, same scripts, same php.ini, httpd.conf is practically the same, the differences in it do not affect in any way php.

coopster

9:41 pm on Jun 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Welcome to WebmasterWorld, masionas.

What are you using for session vars? $_SESSION? Or the long predefined PHP arrays ($HTTP_*_VARS). As of PHP 5.0.0, the long PHP predefined variable arrays may be disabled with the register_long_arrays directive.

masionas

9:55 pm on Jun 7, 2005 (gmt 0)

10+ Year Member



Hi coopster,

Yes, I am using new style $_SESSION array. The strangest is that there is no any error like session cookie can't be sent or alike. It simply does not store session data in the session files and hence the data is not available in the session variables.

coopster

9:58 pm on Jun 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Do you have error_reporting() turned on so you can see any possible messages that are coming back? Also, check your Apache logs to make sure you aren't getting some other form of errors. Permissions-related is a possiblity too.

masionas

10:12 pm on Jun 7, 2005 (gmt 0)

10+ Year Member



I have it in my php.ini rather than in the code
error_reporting = E_ALL & ~E_NOTICE
And no errors in apache logs. And the actual session files are created, but they are not filled.

coopster

10:19 pm on Jun 7, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Hmmm. Odd. Out of curiousity, you're not trying to hit the two different servers as the same domain (like on your lan or virual host) with the same browser at the same time, are you? Try removing all your cookies for that domain in your browser, clear the cache and go to the site that isn't working again.

masionas

10:33 pm on Jun 7, 2005 (gmt 0)

10+ Year Member



I have just tried to access the site via another domain name at all, and it still does not work. ( I have a virtual host with one doc root with a couple domains pointing there. )

masionas

10:39 pm on Jun 7, 2005 (gmt 0)

10+ Year Member



Well, yesterday was such situation. Some period of time domain was resolving to back up server then got back to primary.
>you're not trying to hit the two different servers >as the same domain

But as I said I have just tried different domain which was pointing always to one server.

masionas

2:45 pm on Jun 8, 2005 (gmt 0)

10+ Year Member



Update: After I ran the further testings it has appeared that $_SESSION variable is not persistent from script to script. What could be a problem?

jatar_k

4:59 pm on Jun 8, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



the first thing I would do is build apache the exact same way on both boxes

which one isn't working correctly

masionas

6:55 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



The problem is that I would like to have the most recent apache version which is not in rpm yet, that is why on non-working server I built it from source. Here the last test results:

if I create simple scripts

ses.php


<?
session_start();
$_SESSION["t1"] = "ses_test1";
?>

ses1.php


<?
session_start();
print_r($_SESSION);
?>

It works and data is written to session file and persistent along the site. But the settings from the actual scripts are not committed to file and not persistent. When I fill the $_SESSION array and then print it - it prints it but only on this script output where I filled it in and not another script. But the weirdness that the same actual scripts are working with session ok on another box.

Hence the conclusion is since simplest test session scripts are working, the session handling works with Apache and php. What else left to check? Permissions on the scripts, owner:group, security context?

All ideas are welcome, thank you.

Holzberg

7:52 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



Did you enable sessions in your php.ini?

masionas

8:45 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



Yes, session is enabled and is tracked by session cookie.

masionas

9:31 pm on Jun 9, 2005 (gmt 0)

10+ Year Member



I.e. the value from the simple test script keeps stored and is visible to all the scripts via session variables, but the values are setting in the site scripts are visible only on the script they are setting on.