Re: RE:[PHP] sessions...how to use not clear?
| From: | John W. Holmes | Date: | Tue, 23 Mar 2004 00:38:36 +0000 |
| Subject: | Re: RE:[PHP] sessions...how to use not clear? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-181207@lists.php.net to get a copy of this message | ||
Andy B wrote:
you've already got that unique identifier. it's the username. the username will stay unique visit to visit, therefore you don't need to go against the design of the session id. the session id is not meant to keep uniqueness across multiple visits, only the current visit. are we/me misunderstanding you?Please quote your messages or put a divider between the original content (above) and what you write (below).
yes the username is a thing different from anybody elses login but how will you collect preferences and the like in variables and dump them into a sql table without using a session to define them from everybody elses?? figure this: 1. if you just used a login page and sql table to verify the existance of a username/pwd and once "logged in" you had this code: <?php $color="green"; $show_time="0"; /*dont show the time on the page*/ now somebody else logges in: $color="yellow"; $show_time="1"; (both users are logged in at the same time)?? theory is the variables will conflict with each other...You're confused here. $color loaded from a database in one script is not going to change when another script is run and $color is loaded for another user. The variable is unique to the request.
2. using sessions: <?php session_name($user); session_start(); $_SESSION[color]="green"; $_SESSION[show_time]="0"; now they cant get messed up because: <?php session_name($user); /*user2 now logged in*/ .... will be totally different from user1.This is true and how you want to do it, but using $user inside of session_name() is unecessary. They'll be different because each user has a different session_id by design and that's what's used to identify one users $_SESSION['color'] from anther user's $_SESSION['color']. -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com