Jump to content

Session Troubles On Localhost

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
bbqroast

bbqroast

    Codecall Addict

  • Members
  • PipPipPipPipPipPipPip
  • 554 posts
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.


session_start();

$ID = mysql_result($result,0,"ID");

$Username = mysql_result($result,0,"Username");

$_SESSION['ID'] = $ID;

$_SESSION['Username'] = $Username;

Thanks in advance.
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

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
Hi,

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

Hope this helps!
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.