tags:

views:

59

answers:

2

Hi everyone!

I have a simple form which passes a session variable and it simply fails to load on the second page, I have same version, php 5, on both boxes, works on one not on the other,

I checked to see if session id's were the same, and they are, exactly the same on both pages of the form (NOT on both servers, these are obviously different). Session array is completely empty. session_start(); is the first line of code on all pages of the form.

//this is on first page

session_start();

echo "session id ".session_id();

$_SESSION["gencode"] = $gencode;

//this is on 2nd page

session_start();

echo "session id ".session_id();

echo $_SESSION["gencode"];

Again, I had it working exactly the same on another server, after the move this part broke, should I be looking for a setting somewhere on the server? Both are Linux, if the session_id is echoing that means the same session exists correct?

any advice would help

+1  A: 
  1. Check the php.ini on both servers and confirm the session settings are the same.
  2. var_dump($_SESSION) to see what is in the session. You may see something interesting.
cdburgess
Thanks for your response, I var_dumped $_SESSION and it returned array(0) { } I will look at the php.ini's
Pete Herbert Penito
So we have narrowed it down that the session variables are not getting set. Are you storing session information in the DB? If so, check to make sure a) the session table exists and b) you have permissions to access them.
cdburgess
I'm actually storing them in a dir on the server and I gave it 775 permissions and changed the owner to apache, I'm going to restart apache and see if anything works
Pete Herbert Penito
Try changing the session.save_handler path to something else and see if it works. it will require a restart of apache too.
cdburgess
thanks alot man, it was a permissions issue, much appreciated :)
Pete Herbert Penito
Glad to help. Happy coding!
cdburgess
A: 
  1. Are both pages accessed via exactly the same domain?
  2. Like almost any other PHP function, session_start() can fail, and returns FALSE if it does. Can you check the return value?
Bobby Jack