Help - Search - Members - Calendar
Full Version: How to control the user name throughout the system
MSFN Forums > Coding, Scripting and Servers > Web Development (HTML, Java, PHP, ASP, XML, etc.)

   
Google Internet Forums Unattended CD/DVD Guide
ppa108
I want to control the user name which is loggin into the application. Once the user is logged in, the username should be saved through out the system until the user logged out. For that matter, how can i keep the user name? Should i use cookie or session? How is the difference and which is better?
Is anything sample to use these, please let me see.
Thanks.
dman
A session will not store the username, session is just unique id you can assign on login or initial page load, and check on subsequent requests to make sure it is actually logged in user.
To have the user name available you can either use cookies, or if you want to support browsers with cookies disabled you can pass the name from request to request in a hidden input form field.
Stalkie
You CAN store values (variables) in both sessions and cookies (though many session-engines uses cookies for it).

But the way you do it, depends alot on what language you're using.
dman
QUOTE (Stalkie @ Aug 19 2005, 04:52 AM)
You CAN store values (variables) in both sessions and cookies (though many session-engines uses cookies for it).

But the way you do it, depends alot on what language you're using.
*


You are right of course stalkie.
CODE
// Get the user's input from the form
  $name = $_POST['name'];

// Register session key with the value
  $_SESSION['name'] = $name;


I was thinking of the built-in session variables, but you are correct, you can register your own in the session.
Google Internet Forums Unattended CD/DVD Guide
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.