cfobare Posted April 29, 2015 Share Posted April 29, 2015 I'm trying to have my session continue from my login to home page and follow on pages. This is my login page: http://www.sagginevo.com/EZFurnish/index.php .... I would like the username carry onto the following pages. The Email: Chris Password: 123 Please help. The Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted April 29, 2015 Share Posted April 29, 2015 It sounds like you are using $_SESSION variables. Is the session_start() function being placed at the top of all the scripts that need access to those variables? Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 29, 2015 Share Posted April 29, 2015 why in the name of <insert word(s) here> would you want to carry password info in plaintext through a session ?? Quote Link to comment Share on other sites More sharing options...
cfobare Posted April 29, 2015 Author Share Posted April 29, 2015 I would like to carry the username not the password to the following pages. I have <?php session_start(); // Store Session Data $_SESSION['login_user'] = $username; // Initializing Session with value of PHP Variable echo $_SESSION['login_user']; ?> at the top of the page and <div id="profile"> <b id="welcome">Welcome : <i><?php echo $login_user; ?></i></b> <b id="logout"><a href="logout.php">Log Out</a></b> </div> in the body of the HTML Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 29, 2015 Share Posted April 29, 2015 Do you understand how to get the values from the POST data? The code you provided is missing a lot of things required to actually make this work. Quote Link to comment Share on other sites More sharing options...
cfobare Posted April 29, 2015 Author Share Posted April 29, 2015 The code I used is all located at http://www.formget.com/login-form-in-php/ .... I'm able to validate the user name and password form my db and be directed to my home page. Quote Link to comment Share on other sites More sharing options...
gizmola Posted April 29, 2015 Share Posted April 29, 2015 So -- what isn't working then? Quote Link to comment Share on other sites More sharing options...
Tom10 Posted April 30, 2015 Share Posted April 30, 2015 <?php session_start(); // Store Session Data $_SESSION['login_user'] = $username; // Initializing Session with value of PHP Variable echo $_SESSION['login_user']; ?> session_start doesn't store session data it starts the session, the $_SESSION function stores session data. By the looks of it you are trying to store the username on login and echo it into the index page? Try this: login <?php session_start(); //Start session //This is only an example you store the session data when you are logging in if($count->rowCount > 0) { //Store session data $_SESSION['username'] = $username; } ?> index <?php session_start(); if(isset($_SESSION['username'])) { } else { echo "Couldn't set session!"; } ?> Then you can use <?php echo $username; ?> Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 30, 2015 Share Posted April 30, 2015 since we have taken a pedantic turn here: $_SESSION isn't a function, it's a superglobal variable array. also, you should check for if(!isset()) rather than if(isset()) as the latter can still throw a "Warning: <xxx> is undefined" in the event that the thing you are checking isn't actually set (at least in some older versions of PHP, dont know about the more recent versions because I stopped doing it...). Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.