Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with session vars

Status
Not open for further replies.

JurkMonkey

Programmer
Nov 23, 2004
1,731
CA
Hey Everyone,

I'm trying to create a login page. I need to store the username once validated so I figured, use a session variable...

So I'm setting the variable

Code:
session_register("loginusername");
				$_SESSION["loginusername"] = $_POST["txtUsername"];

Then when I re-post back to the same page I don't have the session variable anymore...

any help?
 
Code:
session_start();
$_SESSION['loginusername']=trim($_POST['txtUserName']);
 
To flesh out jpadie's answer....


If you look at the PHP online manual page for session_register(), you will see a number of yellow blocks marked "Caution". Those cautions make it clear that the recommended practice for registering session variables is to do as jpadie has posted, simply invoke session_start() and populate or depopulate the $_SESSION superglobal array. PHP will take care of the rest.



Want the best answers? Ask the best questions! TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top