Jump to content

Session Problem


nashsaint

Recommended Posts

I have a working user-authentication.  Decided to add another page but put it in a folder 'Newpage' and include different header, css, etc. I used same script to check if user is logged in, created a link from the main page but when navigated to the new page it couldn't remember the Session.  Here's the code for the new page:

 

// If no first_name variable exists, redirect the user.
if (!isset($_SESSION['first_name'])) {

    // Start defining the URL.
    $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']);
    //Check for a trailing slash.
    if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\')) {
        $url = substr($url, 0, -1); // Chop off the slash.

    }
    // Add the page.
    $url .= '/index.php';

    ob_end_clean(); // Delete the buffer.
    header("Location: $url");
    exit(); // Quit the script.
} else {
// If user is logged in

 

The result always takes me back to index.php instead of going to newpage.

Link to comment
https://forums.phpfreaks.com/topic/105039-session-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.