NOTE: This is a collection of information and links collected over the years that might provide useful information. A Safer Company LLC does not guarantee, endorse or approve any of these links or their scripts. Use these links to other websites at your own risk.
PHP Sessions
- session.auto_start : specifies whether the session module starts a session automatically on request startup. Defaults to 0 (disabled).
- session.name : specifies the name of the session which is used as cookie name. It should only contain alphanumeric characters. Defaults to PHPSESSID.
- session.save_handler : defines the name of the handler which is used for storing and retrieving data associated with a session. Defaults to files.
- session.save_path : defines the argument which is passed to the save handler. If you choose the default files handler, this is the path where the files are created. Defaults to /tmp.
- session.use_cookies : specifies whether the module will use cookies to store the session id on the client side. Defaults to 1 (enabled).
- session.use_only_cookies : specifies whether the module will only use cookies to store the session id on the client side. Enabling this setting prevents attacks involved passing session ids in URLs.
- session.cookie_lifetime : specifies the lifetime of the cookie in seconds which is sent to the browser. The value 0 means "until the browser is closed." Defaults to 0.
- session.cookie_path : specifies path to set in session_cookie. Defaults to /.
- session.use_trans_sid : whether transparent sid support is enabled or not. Defaults to 0 (disabled).
session_start();
$_SESSION['username'] = 'John';
session_start(); if ( isset ($_SESSION['username'])) { echo"User : ".$_SESSION['username']; } else { echo "Set the username"; $_SESSION['username'] = 'John'; }
Step 5 - Clean and destroy session
- Call the unset() function to remove a variable from a session.session_destroy() function - be careful with it.
- session_destroy() function to remove all session data
session_start(); if (isset($_SESSION['username'])){ echo "User : ".$_SESSION['username']; session_destroy(); } else { echo "Set the username"; $_SESSION['username'] = 'John'; }
Page last updated: May 31, 2012 10:45 AM
Content and Navigation...