Skip to content

Commit

Permalink
Update docs for accessing request instance
Browse files Browse the repository at this point in the history
  • Loading branch information
ADmad authored Jun 11, 2020
1 parent d628e93 commit 3553d39
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions en/development/sessions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -331,16 +331,17 @@ This means the session is accessible from:
* Cells
* Components

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

$name = $this->getRequest()->getSession()->read('User.name');
$name = $this->request->getSession()->read('User.name');

// If you are accessing the session multiple times,
// you will probably want a local variable.
$session = $this->getRequest()->getSession();
$session = $this->request->getSession();
$name = $session->read('User.name');
In helpers you can use ``$this->_View->getRequest()`` to get the request object
and in component you can use ``$this->getController->getRequest()`.
Reading & Writing Session Data
==============================
Expand Down

0 comments on commit 3553d39

Please sign in to comment.