![]() |
Session data in AJAX Request - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Session data in AJAX Request (/showthread.php?tid=7446) |
Session data in AJAX Request - El Forum - 04-09-2008 [eluser]lookatthosemoose[/eluser] Are session variables not accessible when calling a controller function via ajax? For instance, I have an AJAX request that increments a DB field. The controller function is being called via AJAX, and in that function I'd like to use existing session data, but when I attempt to echo out session variables, I get nothing. See below. Code: [removed] Code: function increment(){ When viewing the AJAX response in Firebug, I only get: Quote:userID is: SO does that mean session variables are not available there? I'm using native sessions not the standard CI sessions. Thanks E Session data in AJAX Request - El Forum - 04-09-2008 [eluser]Pascal Kriete[/eluser] This should work just fine and I don't know why it isn't working, but there is an easy solution. I assume you're already parsing the javascript due to the fact that you're using site_url. So you could just get it directly from php. Code: var user_id = <?= $this->session->userdata('user_id'); |