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 Quote Link to comment 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. Quote Link to comment 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? Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 And you get the login name how? Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
revraz Posted January 27, 2008 Share Posted January 27, 2008 Post the login form you are using. Quote Link to comment 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"> Quote Link to comment 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. Quote Link to comment Share on other sites More sharing options...
affordit Posted January 27, 2008 Author Share Posted January 27, 2008 Thank You I appreciate 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.