Example if ($session->check('name')) {
// name exists and is not null.
}
Delete Session Data To delete data from session, we can use the
delete() session method to delete the data.
Session::delete($key)
The above function will take only key of the value to be deleted from session.
Example $session->delete('name');
When you want to read and then delete data from session then, we can use the
consume() session method.
static Session::consume($key)
The above function will take only key as argument.
Example $session->consume('name');
Destroying a Session We need to destroy a user session when the user logs out from the site and to destroy the
session the
destroy() method is used.
Session::destroy()
Example $session->destroy();
CakePHP
75
Destroying session will remove all session data from server but will not remove session
cookie.