Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 24th, 2005, 03:45 AM
varungupta
Guest
 
Posts: n/a
Default Session generation problem

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 ?

  #2  
Old August 24th, 2005, 09:15 AM
Erwin Moller
Guest
 
Posts: n/a
Default 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
  #3  
Old August 24th, 2005, 09:45 AM
Colin McKinnon
Guest
 
Posts: n/a
Default 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.
  #4  
Old August 24th, 2005, 03:15 PM
varungupta
Guest
 
Posts: n/a
Default 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.

  #5  
Old August 24th, 2005, 04:15 PM
Erwin Moller
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles