Page 1 of 1

Session Problem

Posted: Wed Jun 24, 2009 7:25 pm
by Randwulf
Hullo,

I'm having a problem with sessions. My user's are having to login twice.

Here's the chunk of my login php file where sessions are assigned:

Code: Select all

    
if ($arr['Password'] == $pwHashed)
    {
        session_start();
        $_SESSION['FileP'] = strtolower(str_replace(" ","",$arr['SLName']));
        $_SESSION['Password'] = $pwHashed;
        $_SESSION['Username'] = $uid;
    }
    else
    {
        die ("Invalid Password.");
    }
    header("Location: http://(***************");
And then in the *********** file that the login one headers to, one of the first lines of code run is:

Code: Select all

extract($_SESSION) or die("<a href='http://*****************'>Log in</a>");
Am I just trying to extract the session too quickly after it's initiated? If my users log in again, all works fine.

Thank you.

Re: Session Problem

Posted: Wed Jun 24, 2009 10:08 pm
by Eric!
And then in the *********** file that the login one headers to, one of the first lines of code run is:
Are you calling session_start in the ***** file before accessing your session data?

Re: Session Problem

Posted: Wed Jun 24, 2009 10:30 pm
by Randwulf
Eric! wrote:
And then in the *********** file that the login one headers to, one of the first lines of code run is:
Are you calling session_start in the ***** file before accessing your session data?
Thank you for your response. Yes, I'm calling it before accessing the session data. Any other ideas? :(

Re: Session Problem

Posted: Wed Jun 24, 2009 11:00 pm
by Eric!
I'm stabbing in the dark because I don't know what your two php scripts are doing by only seeing a line or two.

Check the basics, are the variables assigned right? Echo them to check.

Re: Session Problem

Posted: Thu Jun 25, 2009 10:36 am
by Randwulf
The thing is that the *** script dies and sends the user back to the login page, and if they log in again, it works fine. So it's not something syntax related or anything.

Re: Session Problem

Posted: Thu Jun 25, 2009 10:55 am
by Eric!
It never hurts to check them. I can't help much without seeing more code.

Extract is supposed to return the number of variables converted. Have you checked that the session variables are really not stored before running extract? Have you checked that extract is really returning 0? I've never used or die with extract....

Re: Session Problem

Posted: Tue Jun 30, 2009 11:28 pm
by Randwulf
Yeah. I've tried all sorts of stuff :(

I think it might be something with my webhost. I'll contact them.