Hi there, not sure if anyone is familiar with php sessions and centos... but i need some assistance with getting the session to carry from one page to the next. The session can be created and I am able to echo the session vars on the page they were created by, however the vars are empty once you jump onto the next page. I've tried echo'ing out errors and come up with error number 22527 (if that helps?).

Any ideas what may be causing this or whether i should perhaps be looking to some kind of server configuration setting? This is a self-managed private server using Centos 6 edit alongside Apache webserver.

Many thanks in advance!

    Maybe make sure the Apache user has write access on the session data directory?

      Thanks NogDog - have ensured apached does have write access on /var/lib/php/session.

      drwxrwx--- 2 apache apache 53248 Jun 25 22:55 session

      The individual sessions under that directory show the creation of a new session from my web page - the permissions of each of the sessions under that folder are just -rw------- which should be ok?

        I would check to make sure the session_id is being carried over. Try echoing out the [man]session_id/man on the page to see if its changing.

          Thanks Derokorian - ok, this is interesting now... i output the session_id() at 3 points.

          1 - Home page to register an account
          2 - Verification of registration page (i.e. a link received by email - requiring user to re-enter password to make account active)
          3 - Back to home page (but this time it should be in a 'logged in' state - however isnt because of session issues).

          At each stage I seem to be getting a different session_id()

          1 - 6evosh8so496fu3j4g4d1nntd2

          2 - aq7fnfnqu4m98puelvstqr7911

          3 - g0ut714v2c5v6fd4qe9nu3kkr5

          Thoughts?

            My initial thoughts would be that you are not accepting the cookie and/or not sending it back. To check try setting session.use_trans_sid to On in your php.ini so that it passes in the url.

            Another thought is that you have a sub-domain handling one or more pages, if your cookie's domain is set to www.example.com and you visit example.com it will not be sent. Just like if you visited admin.example.com it still wouldn't work. To fix this try setting the necessary values in [man]session_set_cookie_params/man.

            If neither solution works then... post back =D

              WIN!

              The following line, preceding session_start();, has resolved things.

              session_set_cookie_params(0, '/', '.example.com');

              I was a bit reluctant to turn session.use_trans_sid on because i'd rather session_id's sit out of view.

              Thanks very much for your help!

                wilzy wrote:

                I was a bit reluctant to turn session.use_trans_sid on because i'd rather session_id's sit out of view.

                Not a problem if it's just temporarily for debugging.

                  Weedpacket;11006706 wrote:

                  Not a problem if it's just temporarily for debugging.

                  Yeah, that's a fair point!

                    wilzy;11006705 wrote:

                    I was a bit reluctant to turn session.use_trans_sid on because i'd rather session_id's sit out of view.

                    Thanks very much for your help!

                    Glad to hear you got it working. And yes I agree I would never rely on use_trans_sid however if I was having problems with sessions I would use it simply to help narrow down the search.

                      Write a Reply...