affordit Posted January 27, 2008 Share Posted January 27, 2008 first I need to know if this code has to be on every page session_start(); $_SESSION['username'] = $_SESSION['username']; and if it does can it be stored and called from every page? Thanks Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/ Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 session_start(); does I have no idea what you are trying to do with $_SESSION['username'] = $_SESSION['username']; The $_SESSION variable is available on every page you use session_start so there is no need to assign it each time. Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450642 Share on other sites More sharing options...
affordit Posted January 27, 2008 Author Share Posted January 27, 2008 So all I need is this on the page where they log in session_start(); $_SESSION['username'] = $_SESSION['username']; And then if I include this line session_start(); at the top of every other page it will work properly? Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450649 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 No, again, $_SESSION['username'] = $_SESSION['username']; is not doing anything. Set it with something like $_SESSION['username'] = $_POST['username']; Where do you get username from? Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450653 Share on other sites More sharing options...
affordit Posted January 27, 2008 Author Share Posted January 27, 2008 username is the login name and what I need to do is store it in a session im told so it can be used in the other pages Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450657 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 And you get the login name how? Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450660 Share on other sites More sharing options...
affordit Posted January 27, 2008 Author Share Posted January 27, 2008 From the login form I got the username thing from http://www.tizag.com/phpT/phpsessions.php but I guess I am not understanding Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450664 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Post the login form you are using. Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450674 Share on other sites More sharing options...
affordit Posted January 27, 2008 Author Share Posted January 27, 2008 <?php session_start(); // start up your PHP session! ?> <form action="verify.php" method=post> <input type=text name="username"> <input type=text name="psword"> <input type=submit value ="Login"> Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450683 Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Now after you authenticate them as a user, use the line $_SESSION['username'] = $_POST['username']; And that will transfer the Username in the Login script to a Session which you can use on any page that uses sessions. Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450685 Share on other sites More sharing options...
affordit Posted January 27, 2008 Author Share Posted January 27, 2008 Thank You I appreciate it. Link to comment https://forums.phpfreaks.com/topic/88087-solved-sessions-question/#findComment-450686 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.