Notice: Undefined index: checkdate in /var/www/html/wp-content/plugins/whmcs-bridge-sso/includes/license.class.php on line 57
How to read write and delete session in CakePHP? – skyX

How to read write and delete session in CakePHP?

by

Session in PHP

PHP Sessions allows you to identify unique users across requests and store persistent data for specific users against a unique session ID. This can be used to persist state information between page requests. Session IDs are normally sent to the browser via session cookies and the ID is used to retrieve existing session data.

Reading, Writing and Deleting session in Cakephp 3.x

You can access the session data any place you have access to a request object. This means the session is accessible from:

  • Controllers
  • Views
  • Helpers
  • Cells
  • Components

In addition to the basic session object, you can also use the Cake\View\Helper\SessionHelper to interact with the session in your views. A basic example of session usage would be:

Reading, Writing and Deleting Session Data

Session::read($key) function is used to read specific session data in CakePHP.

Session::write($key, $value) function is used to write session data in CakePHP.

Session::delete($key) function is used to delete specific session data in CakePHP.

Sample Usage

 


Recommended Posts

Leave a Reply

Your email address will not be published. Required fields are marked *