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 Link to comment https://forums.phpfreaks.com/topic/295948-session_start/ 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? Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510294 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 ?? Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510296 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 Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510308 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. Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510312 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. Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510318 Share on other sites More sharing options...
gizmola Posted April 29, 2015 Share Posted April 29, 2015 So -- what isn't working then? Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510343 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; ?> Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510387 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...). Link to comment https://forums.phpfreaks.com/topic/295948-session_start/#findComment-1510390 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.