On Tue, Oct 14, 2003 at 05:23:54PM -0800, Chris Hubbard wrote:
> to use php sessions:
> you will need some place where you set up/create the sessions.  typically
> this is the login page.  let's assume you'll use the login page.  The logic
> for the login page goes something like this:
> 1.  present a form for logging in (usually username/password)
> 2.  on post, clean the posted data (remove html, special characters, etc)
> 3.  check the cleaned username/password against the data in the database
> 4.  if the username/password is valid, create your session and assign
> variables to it like this:
>       session_start();  //create the session
>       $id = session_id();  // create a unique session id
>       session_register("id");  // register id as a session variable
>       session_register("name");  // register name as a session variable
>       session_register("email");  // register email as a session variable
>       $_SESSION["id"] = $id;  // assign the unique session id to session array
>       $_SESSION["name"] = $data["name"];  // assign the username to session array
>       $_SESSION["email"] = $data["email"];  // assign additional values (after
> regisering them) to session array
> 
> Hope this is helpful.
> 
> Chris
> 

There is no need to register variables as a session variable if
register_globals is foff. The manual states:

If you want your script to work regardless of register_globals, you need to
instead use the $_SESSION array as $_SESSION entries are automatically
registered. If your script uses session_register(), it will not work in
environments where the PHP directive register_globals is disabled.

So the three 'session_register' statements above should be removed.

-- 
Jim Kaufman             mailto:[EMAIL PROTECTED]
Linux Evangelist        cell: 612-481-9778              
public key 0x6D802619   fax:  952-937-9832
http://www.linuxforbusiness.net
---
Any smoothly functioning technology will have the appearance of magic.
                -- Arthur C. Clarke

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to