Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Session variables not registering

session session variable registering

  • Please log in to reply
2 replies to this topic

#1 avingard


    CC Lurker

  • Just Joined
  • Pip
  • 8 posts

Posted 10 June 2008 - 06:52 AM

I'm registering session varibles using $_SESSION[] and they aren't staying registered. I know that sounds weird, but I've tried and when I echo the session variable on the first page (before redirecting using header('location: page.php')) it shows up fine; however, after the redirect, the session variable always fails isset().

What am I missing? Anyone know what could cause this?
  • 0

#2 veridicus


    CC Lurker

  • New Member
  • Pip
  • 5 posts

Posted 11 June 2008 - 06:48 AM

Questions: Are you tracking sessions using cookies or the URL? Did you check to see if the sessions are being properly written to disk (or database)? Do you call session_start at the very beginning of your scripts before any output?
  • 0

#3 Whitey


    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 259 posts

Posted 11 June 2008 - 01:42 PM

Well first you must have session_start() on all the page's you are using the session variable on. And it must be at the top (or above the head tags).

And this is how i register a session..

$_SESSION['username_taken'] = "<center><font color='red' size='1'>The Username You Chose Is Already In Use</font></center>";

Then on the page that you are viewing the session you would do this

echo ($_SESSION['username_taken']);

  • 0

Also tagged with one or more of these keywords: session, session variable, registering

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download