Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Session Troubles On Localhost


  • Please log in to reply
1 reply to this topic

#1 bbqroast


    Codecall Addict

  • Senior Member
  • PipPipPipPipPipPip
  • 564 posts
  • Location:/etc/passwd

Posted 17 December 2010 - 11:11 AM

I'm having some very persistant troubles with sessions.
Once you click login you are sent to the same login page. If you have not logged in correctly a message appears at the top of the box.
If you have it sets "goahead" to true. In some code (slightly down from the other but still before the <HTML> tag) I check if goahead is set to true and then start and set a session.
Later on in the ,<head> tags I check again and do a redirect using javascript.

What happens:
I login, I get redirected to the profile page but the session hasn't started!?!
I just took out the redirect and made PHP echo "hi" after setting the session vars.
Sure enough "hi" appeared at the top of the page.

This is the code that does the sessions.

$ID = mysql_result($result,0,"ID");
$Username = mysql_result($result,0,"Username");
$_SESSION['ID'] = $ID;
$_SESSION['Username'] = $Username;

Thanks in advance.
  • 0
Please, write clearly with proper structure. Double spacing makes the text feel un-jointed, Capitalizing Every Word Means People Stop Before Every Word Sub-Consciously Which Is A Pain In The Backside, and use code tags! (The right most styling box).

#2 Alexander



  • Moderator
  • 3963 posts
  • Location:Vancouver, Eh! Cleverness: 200
  • Programming Language:C, C++, PHP, Assembly

Posted 17 December 2010 - 12:23 PM


Had you printed out the session on the profile page to verify its contents?

Hope this helps!
  • 0

All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.

Also tagged with one or more of these keywords: session

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