nashsaint Posted May 10, 2008 Share Posted May 10, 2008 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 More sharing options...
DarkWater Posted May 10, 2008 Share Posted May 10, 2008 Put session_start() on top of the page! > Link to comment https://forums.phpfreaks.com/topic/105039-session-problem/#findComment-537684 Share on other sites More sharing options...
nashsaint Posted May 10, 2008 Author Share Posted May 10, 2008 Tnx DarkWater Link to comment https://forums.phpfreaks.com/topic/105039-session-problem/#findComment-537823 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.