weixin_33738578 2013-12-30 21:13 采纳率: 0%
浏览 40


I'm having a lot of trouble working with CakePHP sessions and AJAX. I have an AJAX login that I use Auth->login() with, and then I add some extra parameters to the end with Session->write().

$this->Session->write('Auth.User.id', $user_grab['User']['id']);
$this->Session->write('Auth.User.auth_level', $user_grab['User']['auth_level']);
$this->Session->write('Auth.User.successful', 3);

I am using Configure::write('Session.checkAgent', false); as per some suggestions I've read.

The problem is any time I set inside this AJAX, it won't be there on any other page load: even if I do the AJAX again, after writing, and just do a read(), the read() will be empty. It's as if it just ignores the AJAX completely. Yet if I:


 $this->Session->write('Auth.User.successful', 3);


I will see what's supposed to be in the session, it just won't truly save. I can save anywhere else in non-ajax parts of the application, even just setting test session data on the index of the site. It persists.

I'm completely stuck. It seems unrelated to using Auth->login(). I am using, in AppController, both Session and Auth.

Expected behavior: being able to Session->write() in AJAX and have what I wrote be available anywhere else. To test, I was using a test action with a simple debug($_SESSION) and debug($this->Session->read()).

  • 写回答

1条回答 默认 最新


      相关推荐 更多相似问题


      • ¥60 iPad应用程序UPV打开Windows系统相同应用下的模型文件
      • ¥15 MySQL行转动态列的问题
      • ¥15 通过STM32F4实现智能清洁小车,要求用到三个以上传感器
      • ¥15 perl代码解释说明
      • ¥15 列举 五阶幻方 有多少种
      • ¥15 请教一下能人在VS中调用MATLAB绘制动态驻波
      • ¥15 VB.NET如何调用Microsoft Excel?(WPS存在时)
      • ¥15 KUKA机器人EtherNetIP通讯配置教程
      • ¥15 VB6.0如何模拟键盘组合按键
      • ¥15 python怎么替换这个word里边内容