minte9
LearnRemember



Session

Session is started before loading classes. This makes storing objects in the session impossible.

Start

Session can be started from your script. Also, you can start session automaticaly in php.ini
 
session_start();
 
session.auto_start = 1

Access

Sessions are used to create persistent client state between request. Sessions are stored on servers, cookies on clients. For accesing date we use $_SESSION.
 
// Set a session variable
$_SESSION['hide_menu'] = true;

// From here on, we can access hide_menu in $_SESSION
if ($_SESSION['hide_menu']) {}

Security

In the interest of security, it is a good idea to follow your call to session_start() with a call to session_regenerate_id() whenever you change a user's privileges to prevent "session fixation" attacks.


  Last update: 303 days ago