Using Cookies with Session

When you are using PHP sessions, you do not have to manually set cookies. The session functions take care of this task for you.

You can use the function session_get_cookie_params() to see the contents of the cookie set by session control. It returns an array containing the elements lifetime, path, domain, and secure.

You can also use

sesion_set_cookie_params($lifetime [, $path [, $domain [, $secure]]]);
to set the session cookie parameters. The effect of this function lasts only for the duration of the script. Thus, you need to call the function for every request and before session_start() is called.


Sessions in PHP | Introduction | Basic Session Functionality | Creating a Session | Accessing Session Variables | Deleting a Session | Implementing a Login System with Sessions | Saving Arrays in a Session | Using Cookies with Session | Sessions without Cookies | Potential Session Problems
© 2008: Hann So
email: hso@voyager.deanza.edu