开发者

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

开发者 https://www.devze.com 2023-01-09 22:33 出处:网络
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开发者

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

精彩评论

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

关注公众号