neridaj Posted April 22, 2008 Share Posted April 22, 2008 Hello, I don't know why this immediately redirects hen I hit the page: session_start(); $_SESSION['valid_user'] = $username; if(!isset($_SESSION['valid_user'])) header('Location:http://www.listingsbox.com'); die("Your session has expired!"); Thanks for any help, J Link to comment https://forums.phpfreaks.com/topic/102280-session-immediate-timeout/ Share on other sites More sharing options...
marcus Posted April 22, 2008 Share Posted April 22, 2008 sessions will only pass on the domain itself if you're sending from http://listingsbox.com and redirecting to http://www.listingsbox.com it'll timeout Link to comment https://forums.phpfreaks.com/topic/102280-session-immediate-timeout/#findComment-523718 Share on other sites More sharing options...
rameshfaj Posted April 22, 2008 Share Posted April 22, 2008 if it is due to the expiry of the session values then check and configure properly the session timeout values in the configuration files-php.ini. Link to comment https://forums.phpfreaks.com/topic/102280-session-immediate-timeout/#findComment-523788 Share on other sites More sharing options...
PFMaBiSmAd Posted April 22, 2008 Share Posted April 22, 2008 Your posted code redirects when $username is not defined. The assignment statement setting the session variable to an un-defined variable, does not set the session variable. Link to comment https://forums.phpfreaks.com/topic/102280-session-immediate-timeout/#findComment-523866 Share on other sites More sharing options...
neridaj Posted April 22, 2008 Author Share Posted April 22, 2008 $username is defined at login: // include function files for this application require_once('bookmark_fns.php'); session_start(); if ($username && $passwd) // they have just tried logging in { try { login($username, $passwd); // if they are in the database register the user id $_SESSION['valid_user'] = $username; } catch(Exception $e) { echo $e->getMessage(); // unsuccessful login do_html_header('Problem:'); do_html_url('login.php', 'Login'); do_html_footer(); exit; } } Link to comment https://forums.phpfreaks.com/topic/102280-session-immediate-timeout/#findComment-524471 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.