2

I'm using ajax and sessions for a cakephp project but it looks like the session gets lost when I use either safari or IE. I've followed the solutions in Sessions in IE and cakephp 1.3 not working properly when saving via AJAX I've set my core.php files to the settings below.

  Configure::write('Session.checkAgent', false);
  Configure::write('Security.level', 'low');

I've already upgraded my cake version to 2.3.0 and I'm still having the same issues. Please help? Thank you.

Here are my pastebins

jscript http://pastebin.com/WDCaTkEH

php - http://pastebin.com/YL7qkLf0

Community
  • 1
  • 1
gerl
  • 1,161
  • 2
  • 17
  • 53
  • Does the script work in other browsers? Have you tried to 'echo' the result in stead of 'returning' it? Also you're returning 'true' inside PHP, but check for '1' inside JavaScript. And finally, you're using a 'relative' URL for your Ajax request (`participants/ajax_index`), maybe it's better to use an absolute path, starting with a `/` (`/participants/ajax_index`) to prevent the browser *appending* it to the current URL, which will become `/participants/ajax_index/participants/ajax_index` – thaJeztah Mar 01 '13 at 21:25
  • Hey, It's working in chrome & firefox. I'm using IE's developer tools debugger for this on why my ajax is failing. A variable is found to be null when it shouldnt be. It should pick up the value through $this->Session->read('id') where id is my variable name. I am using a relative path but I dont think that should matter right? since it's working in firefox and chrome? – gerl Mar 01 '13 at 21:49
  • The relative path should not matter if it is posting/requesting the right URL, I just thought it was worth mentioning because I've ran into that problem in the past. If you're watching the request-headers in Safari inspector, does it contain a Session-cookie header? – thaJeztah Mar 01 '13 at 22:11

2 Answers2

3

there seems to be something wrong with cake somewhere ... adding session_start(); as first line on webroot/index.php solved the issue for me.

Bsfjam
  • 31
  • 2
  • I was having the same problem on mobile safari, iOS 5 (what debugging tools?). This fixed the issue for me. I still want to know why(!) but thank you. – trey-jones May 14 '14 at 20:50
0

I am using version 2.9. I add session_start(); in webroot/index.php -- It solved my problem There is something wrong in Cakephp.

user2126372
  • 31
  • 1
  • 6