Connecting Tech Pros Worldwide Forums | Help | Site Map

Session generation problem

varungupta
Guest
 
Posts: n/a
#1: Aug 24 '05
Hi Group members !

We are hosting a Apache/PHP/MySql based website at our college since
January,2005. It was working fine since then. The web server is plaed
in our college itself and we are using IP binding method to make it
available globally.

We are having a login page which redirects the user again to home page
after authentication but with a session started. But the problem was
that every time the user enters his username and password, he was
redirected to home page but no session was genrated i.e. he is logged
in.

We tried to work out a solution for the problem but coudn't find one.
But to our surprise, the site started working normally on its own after
about 3 hours.

But yesterday, the same problem again surfaced and again we had no
solution. Thinking of past instance, we waited for many hours but the
problem sustained.
And still our site is affected with that problem.

The tecnical information :
Web server : Apache 2.0.52 Build Oct 15, 2004
PHP interpreter : PHP 4.3.9 Build Oct 20, 2004
Operating System : Linux Fedora Core 3

Can anyone suggest any solution or reference for the problem ?


Erwin Moller
Guest
 
Posts: n/a
#2: Aug 24 '05

re: Session generation problem


varungupta wrote:
[color=blue]
> Hi Group members !
>
> We are hosting a Apache/PHP/MySql based website at our college since
> January,2005. It was working fine since then. The web server is plaed
> in our college itself and we are using IP binding method to make it
> available globally.
>
> We are having a login page which redirects the user again to home page
> after authentication but with a session started. But the problem was
> that every time the user enters his username and password, he was
> redirected to home page but no session was genrated i.e. he is logged
> in.
>
> We tried to work out a solution for the problem but coudn't find one.
> But to our surprise, the site started working normally on its own after
> about 3 hours.
>
> But yesterday, the same problem again surfaced and again we had no
> solution. Thinking of past instance, we waited for many hours but the
> problem sustained.
> And still our site is affected with that problem.
>
> The tecnical information :
> Web server : Apache 2.0.52 Build Oct 15, 2004
> PHP interpreter : PHP 4.3.9 Build Oct 20, 2004
> Operating System : Linux Fedora Core 3
>
> Can anyone suggest any solution or reference for the problem ?[/color]


Hi,

That is a really weird problem.
Next time you are unable to start session, do some testing.

Here are some things of importance to get a general idea.
I take it you store session in a temp-dir serialized (which is default
behaviour). If you use a database to store session, do something similar as
I decribed here to hunt down the bug.

0) Download Firefox as browser if don't have that already.
1) Thow away all your cookies.
2) Log into the system via the website as you always do.
3) check if a cookie is placed. It will have a name like: PHPSESSID and it
will contain a whole lot of random characters.
Note that string.
4) Look on the machine where PHP is running and check the temp-dir.
(You can find the temp-dir in php.ini, or when it is not set there: it is
the default tempdir, like /tmp)
5) Do you see a file in there with the same number-characterstring as the
cookie contained?

What do you find?

Regards,
Erwin Moller
Colin McKinnon
Guest
 
Posts: n/a
#3: Aug 24 '05

re: Session generation problem


varungupta wrote:
[color=blue]
>
> We are having a login page which redirects the user again to home page
> after authentication but with a session started. But the problem was
> that every time the user enters his username and password, he was
> redirected to home page but no session was genrated i.e. he is logged
> in.
>
> We tried to work out a solution for the problem but coudn't find one.
> But to our surprise, the site started working normally on its own after
> about 3 hours.
>
> But yesterday, the same problem again surfaced and again we had no
> solution. Thinking of past instance, we waited for many hours but the
> problem sustained.
> And still our site is affected with that problem.
>[/color]

The default session handler does not scale well, although I suspect the
problem may lie elsewhere (permissions on session dir? disk space?).

Try using a MySQL session handler.

C.
varungupta
Guest
 
Posts: n/a
#4: Aug 24 '05

re: Session generation problem


Hi Erwin !

Its great to have reply from your side.
I have checked all the points mentioned by you and found that the
session is starting and cookies are generated on both server as well as
client side.
We have tried a test script to check session handling.
We started a general session by simply using session_start() and found
that the session was successfuly generated. We even stored and
successfully retrieved values on the same page but when we moved to
next page the session was not there, i.e. session was not continued on
next page.
Now please enlighten me.

Erwin Moller
Guest
 
Posts: n/a
#5: Aug 24 '05

re: Session generation problem


varungupta wrote:
[color=blue]
> Hi Erwin !
>[/color]

Hi,
[color=blue]
> Its great to have reply from your side.[/color]

*blushes*
[color=blue]
> I have checked all the points mentioned by you and found that the
> session is starting and cookies are generated on both server as well as
> client side.
> We have tried a test script to check session handling.
> We started a general session by simply using session_start() and found
> that the session was successfuly generated. We even stored and
> successfully retrieved values on the same page but when we moved to
> next page the session was not there, i.e. session was not continued on
> next page.
> Now please enlighten me.[/color]

Ok, always good to make a few simple scripts to test this. :-)

so: page1.php starts a session.
page2.php tries to read the session (without succes).

Try to add on page2.php some things like:
- echo session_id()
- dump all cookies print_r($_COOKIES);

what do they say?

and maybe read up here (if you didn't do so already)
http://nl2.php.net/manual/en/ref.session.php


Last resort:
I had some (confusing) trouble with Sessions before, when using
session_start().
I switched to 'session.auto_start' by modifying php.ini, and I never had
problems again. :-/
If you can modify php.ini, you could give that a try.
You can also delete all session_start() from your scripts then. :-)

Hope that helps a bit.
It is always difficult to debug a remote system. :P

Reagrds,
Erwin Moller


Closed Thread