开发者

Cakephp Session variable problem

I have 2 controllers, I am setting a session variable in one controller and trying to access it in the other.But its not taking the value I am assigning.

In the first Controller,

$this->Session->write('category',$id);
echo $this->S开发者_开发百科ession->read('category');  //Outputs 17 which is correct

IN the Second controller,

echo $this->Session->read('category'); //Outputs images.jpg

I have checked,the session variable category is never taking a value of images.jpg.


It can be one of two things:

1) remember to load the session component in app_controller

<?php
App::import('Lib', 'permission/Permission');
class AppController extends Controller {
    var $components = array('Session');
}
?>

2) in the core.php file in the config folder you may have the session.start variable set to false

Configure::write('Session.start', true);

This variable says to autostart the session or not.

EDIT: I read wrong sorry, you are changing your variable somewhere try changing the name of the variable to categoryid or something like that, if it works it means that indeed you are changing it somewhere. If you are in linux do a grep -R "$this->Session->write('category'"

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜