weixin_39924307 2020-11-21 20:15
浏览 0

Session::key('session_id') returns false first time it is called

The following simple controller highlights the issue I am having -

 php
<?php /**
 * Test Controller.
 *
 *   app
 *   Controller_Rest
 */
class Controller_Test extends Controller_Rest {

    public function before() {
        parent::before();
        $this->session = \Fuel\Core\Session::instance();
    }

    public function action_test() {
        $this->session->set('user_id', 12345);
        $this->response(array('sessionId' => $this->session->key('session_id')));
    }
}

I need to be able to retrieve the key so that it can be sent as part of a JSON response as the client does not support cookies. The first time that I call /test/test I receive - {"sessionId":false} but on subsequent requests it generates - {"sessionId":"9dddf3fcb058c181bee70e0238581880"}

该提问来源于开源项目:fuel/core

  • 写回答

0条回答 默认 最新

    报告相同问题?