dmccabe Posted May 28, 2008 Share Posted May 28, 2008 Ok I am creating a form to be filled out online, but before filling in the form I want people to authenticate against my ldap server. The authentication is fine, but I want it to then pass the username to the next page where they fill in an online form. I believe the best way is to use a session, but I have looked at the sessions help on php.net and am not getting anywhere fast, so can someone give me a quick example and explanation of how this would work? To recap, I am simply wanting to pass the username they enter in to a form to the next page and then use it later in that page. Link to comment https://forums.phpfreaks.com/topic/107627-using-sessions-to-pass-variable-from-one-page-to-another/ Share on other sites More sharing options...
rhodesa Posted May 28, 2008 Share Posted May 28, 2008 On any page in which you want to access the SESSION (either writing the username or reading from it), you must first start the session: session_start(); that line should be the very first line of the file (well, second line site <?php should be first) Then, in the script, you can read/write to the variable $_SESSION (which is an array): $_SESSION['username'] = 'foobar'; //Set username here and read from it on other pages: print $_SESSION['username']; Link to comment https://forums.phpfreaks.com/topic/107627-using-sessions-to-pass-variable-from-one-page-to-another/#findComment-551673 Share on other sites More sharing options...
dmccabe Posted May 28, 2008 Author Share Posted May 28, 2008 Exactly what I was after, thank you kindly! Link to comment https://forums.phpfreaks.com/topic/107627-using-sessions-to-pass-variable-from-one-page-to-another/#findComment-551679 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.