Jump to content


Photo

Session, $_SESSION and using variables: PROBLEM


  • Please log in to reply
1 reply to this topic

#1 nembrionic

nembrionic
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 March 2006 - 08:13 PM

PHP Version 4.4.1

Here's one for ya all:

My script starts a session.
It then pulls some data from MySQL database.
It saves the pulled variables and values in $_SESSION.

I want to use the new variables and their values straight away.
I print the contents of $_SESSION and I see they are all in there like they should.
Very nice.

However, it will not echo/print them. They are 'empty'
BUT...If I refresh the page, it WILL show them.


So, it doesn't show them the FIRST time, but they WILL show them after a refresh, or visiting another page in my project.

Anyone got a clue why it shows the variables are neatly stored but not printed the first time?



#2 nembrionic

nembrionic
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 14 March 2006 - 09:57 PM

Hmmm somebody just told me that the newly inserted variables are NOT global instantly and thus can not be used on the same page (which is weird as they DO show up in the print of $_SESSION).

So I'm using $GLOBALS now instead of $_SESSION and it works like a charm.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users