ppa108 Posted August 17, 2005 Share Posted August 17, 2005 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. Link to comment Share on other sites More sharing options...
dman Posted August 19, 2005 Share Posted August 19, 2005 (edited) 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. Edited August 19, 2005 by dman Link to comment Share on other sites More sharing options...
Stalkie Posted August 19, 2005 Share Posted August 19, 2005 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. Link to comment Share on other sites More sharing options...
dman Posted August 19, 2005 Share Posted August 19, 2005 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.<{POST_SNAPBACK}>You are right of course stalkie.// 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. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now