Forum Moderators: coopster

Message Too Old, No Replies

PHP Session variables values LOST

from page to page

         

emptiness

4:38 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



Hi everybody, I'm having a huge problem. All the php session variables that I'm using in my site are not working in the hosting server.

When I tested it here, with an IIS they work without problems and they also were working in the hosting server few days ago.

The last modification I made to the pages was yesterday. I added a java script to validate forms. Didn't chek if the pages were working fine before that. So I don't know if the problem is because of the java script modification or if there's something wrong with the provider's hosting server.

I guess the java script should not interfere with the PHP variables... The fact that the pages are working without problems in my server makes me beleive this.

I have no idea of what to do. Tryed initializing the session manually adding "session_start();" to the pages, but didn't work.

PLEASE HELP ME!

lorax

4:50 pm on Jul 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> session_start();

That needs to be the first line of PHP code for each page that requires access to the session vars.

Have you tried printing one of the session vars to screen just to see if it's actually there? Somewhere around here I think jatar_k had a nice code block that would allow you to print out all of the session variables. I'll see if I can find it.

RonPK

4:54 pm on Jul 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



You mean print_r($_SESSION);?

jatar_k

5:42 pm on Jul 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



yes but add this around it

echo "<pre>";
print_r($_SESSION);
echo "</pre>";

that makes it readable on screen, otherwise you have to view source which is just one extra step but when doing complex debugging every saved step helps reduce the annoyance factor. ;)

jatar_k

5:48 pm on Jul 13, 2004 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



sorry emptiness,

I didn't answer your concern just took it a little OT.

First thing to do is approach this calmly and systematically. Only try one thing at a time to isolate the problem. Some thoughts on a way to approach this.

I doubt it is the javascipt, but never leave any stone unturned. I just wouldn't start with this.

The first thing that comes to mind is "Tryed initializing the session manually adding "session_start();" to the pages"

Was it not on the pages before? That could cause a problem. Did you ptu it right at the top of your code?

First thing, try that snippet of code I popped in above. Try it with your pages as is and record the results then add the session_start() to one page (preferably the one from the prevuious page) and try it again and see if the results change.

Then come back and explain to us what happened (error messages, whether the session was there, whether session data was there, etc) and we can go from there.

emptiness

7:00 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



Thanks a lot for been there. I'll try your suggestions right now. Will come back here to let you know how is it going.

I already talk with the provider, says everything is ok with the server (damn) and leave a php test page for me to see that session variables are working (and they are).

I didn't have the session_start() before, thought that they configured PHP to do it automatically (as I did here). Not sure if I put it at the first line...

Well.. thanks again. I'll be back soon.

emptiness

8:58 pm on Jul 13, 2004 (gmt 0)

10+ Year Member



Well, thanks A LOT. It was very simple to solve, thanks to you. The session_start() wasn't in the first line of the pages. Doing that everything managed to work without problems again.

I'm very happy. :)

Thanks again for your help bros