开发者

CakePHP - how do I access the session from a plugin?

I thought I would be able to get a session variable from within a plugin component with $this->Session->var but it looks like $this->Session is not available. How do I access the session from the开发者_开发技巧 main app?


Because the Session is the component you need to include it with:

<?php
  class MyComponent extends Object {
    // This component uses other components
    var $components = array('Session', 'Math');
    function doStuff() {
      $result = $this->Math->doComplexOperation(1, 2);
      $this->Session->write('stuff', $result);
    }
  }
?>

You should check this from where the sample is taken.


This might help you out: http://book.cakephp.org/view/173/Sessions

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜