-4

Possible Duplicate:
PHP Session Id changes between pages

I have an issue regarding sessions on the live server. The previous developer coded the site and all was working fine until we had to upgrade the server to php 5.2 last week. Then all the sessions stop working and users were unable to log in. I removed the use of session_register etc but nothing worked.

For a simple test, I copied a very simple session script from php.net and tried it on my machine and it worked. Once I loaded it onto the server, the second page would not display the session variable I created in the first page.

Is there any configuration that needs to be set up on the server in order to pass session variables?

I used print_r($_SESSION) on page one and it showed the session created, i used it again on page two and the array was empty.

Any help or suggestions would be greatly appreciated.

edit:

    session_start();

was included on all pages and

    print_r($_SESSION)

showed on page 1 that the session was created and that on page two it was not passed

Community
  • 1
  • 1
wibble
  • 1
  • 1
  • 2
    From what version did you upgrade? You are aware that the stable PHP version is 5.4.x, and there's a 5.5 coming up soon, right? Also, please give us a reproducible piece of faulty code. – Madara's Ghost Nov 28 '12 at 21:00
  • 1
    Do you know if the session has started? i.e. session_start() http://www.php.net/manual/en/book.session.php – Benjamin Powers Nov 28 '12 at 21:01
  • More code please. Show us what you have done. Probably need to show the page you created it on and what you are putting on the pages that you are trying to pass to. – Gene Parmesan Nov 28 '12 at 21:03
  • It's a very common problem and there are a multitude of questions and answers on SO, use the search function please! – markus Nov 28 '12 at 21:05
  • I upgraded from 5.1.6. The upgrade was out of my hands, I couldn't control the version number. – wibble Nov 28 '12 at 21:19
  • @markus-tharkun, i spent ages going through the answers and was unable to find out dealing with a server upgrade. The code was working fine until the upgrade, now the server will not pass even the simplest of data from one page to another – wibble Nov 28 '12 at 21:22
  • my test code was taken from php.net copied and pasted from example 1 - http://php.net/manual/en/function.session-start.php. It was just to check are session variables being passed. – wibble Nov 28 '12 at 21:24
  • Then we probably need more information about the server and more code. I would like to underline that PHP 5.2 is terribly old. – markus Nov 28 '12 at 21:59
  • Hello all, Thanks for the suggestions, it turns out the problem was when the update took place the php support in the CP was running as a CGI application, it needed to run as an Apache Module. Noted on the using of the old php version, I am in the process of moving the site to a different server and platform and needed this for an interim fix. Thanks again. – wibble Nov 29 '12 at 02:59

1 Answers1

1

Did you start the session using session_start()? - http://php.net/manual/en/function.session-start.php

danielrsmith
  • 4,050
  • 3
  • 26
  • 32
  • yes, the code I used was super simple because I wanted to determine were sessions being created. – wibble Nov 28 '12 at 21:20