Header menu

_________________________________________________________________________________
Showing posts with label cakephp session. Show all posts
Showing posts with label cakephp session. Show all posts

Thursday, 12 September 2013

Get session information in cakephp

How to get session information in cakephp 

In the controller you can use

$this->Session->read();

to get all details of session variable . And you can use

$this->set('session',$this->Session->read());


to use these values in corresponding view page.

-----------------------------------------------------------------------------------------------------------------------

If you wish to use session variable in each page then use set method in appcontroller to set its value

public function beforefilter(){
$this->set('session',$this->Session->read());
}

Now this session variable is accessible in every page of view.

Note: this should be placed in Appcontroller...

Monday, 9 September 2013

Session variable in cakephp

PHP session  allows you to store user information on the server for later use (i.e. username, time,visited urls etc), this information is temporary and
will be deleted after the user has left the website.

To access session variable in cakephp... Go to controller in which you want to see session variable and add following two lines in code..

$session=$this->Session->read();
pr($session);