SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session data not being passed?

    Could I get some help as to why session variable information is not being passed?

    This is just a simple log in script that I've used dozens of times, but I'm working with a new hosting server and things are being jacked up.

    After I've checked the db for user info (login and password) I start my session and create a session variable to tell my authentication script that the user is logged in (setting $_SESSION['logged_in'] to true).

    PHP Code:
    session_start();
    $_SESSION['logged_in'] = TRUE;
    while(
    $row mysql_fetch_assoc($result))
        {
            
    $id $row['id'];
        }
    $_SESSION['id'] = $id;
    header('Location: /admin'); 
    I'm including this authentication in all my scripts.

    PHP Code:
    session_start();
    if(
    $_SESSION['logged_in'] !== TRUE) {
        
    session_destroy();
        
    header('Location: login.php');
    }else{
    $uID $_SESSION['id'];
    }
    ini_set('session.bug_compat_42',0);
    ini_set('session.bug_compat_warn',0); 
    This works fine on my local machine (MAMP). However, on the production server, $_SESSION['logged_in'] is not set (or something because it's not equal to true when I test it).

    I should clarify. When testing the login script, the session variable does get set to true. After it forwards to the index page, it's reset, or lost, or whatever it is that happens to it.

    Could I get some help on resolving this please? Thanks in advance.
    No, I REALLY dislike having to use Joomla.

  2. #2
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    And I see this error:

    Warning: session_start() [function.session-start]: open(/var/php_sessions/sess_018f62a492fd7b0b0090e456abb304b5, O_RDWR) failed: No such file or directory (2) in /hermes/web08/b761/as.jensensliquors/public_html/admin/incs/auth.php on line 5
    How is it that it saves the session data to a file but is unable to open or find that file in subsequent requests?
    No, I REALLY dislike having to use Joomla.

  3. #3
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Are you sure it ever saved it? Check permissions on /var/php_sessions, see if there are actually files there, that your server isn't out of disk space on that partition, etc.

  4. #4
    derrrp
    Join Date
    Aug 2006
    Location
    earth
    Posts
    923
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reply Dan. I ended up using session_save_path() to declare my own directory...works now.

    I couldn't even find '/var/php_sessions' but that just may be out of my permissible FTP access.
    No, I REALLY dislike having to use Joomla.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •