CodeIgniter Forums
Session Data for AJAX Calls in CI 3.x?—SOLVED - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Session Data for AJAX Calls in CI 3.x?—SOLVED (/showthread.php?tid=66657)



Session Data for AJAX Calls in CI 3.x?—SOLVED - VikRubenfeld - 11-18-2016

UPDATE: My boss is telling me I will have to revert to CI 2.x if I can't get this fixed by Monday.

Is there anything I can look at to start to track this down?

I've just upgraded to CI 3. On my development server everything is working great. I'm trying it out now on my production server and I notice that on AJAX calls, $CI->session->userdata has a value in the field for __ci_last_regenerate, but the other fields (status, user_id, and username) are blank. The system thinks the user is not logged in.

Thanks very much in advance to all for any thoughts/info/directions/pointers.


RE: Session Data for AJAX Calls in CI 3.x? URGENT - VikRubenfeld - 11-18-2016

It's not an ajax call-- my apologies. It is a call in javascript, but it's not ajax-- it is:

PHP Code:
window.location "https://myHostName/myController/myFunction/"

Why would it make any difference to the session, if a URL is called this way, rather than entered in the browser URL bar?


RE: Session Data for AJAX Calls in CI 3.x?—SOLVED - VikRubenfeld - 11-18-2016

Using relative URLs fixed it:

Before (not working):
Code:
window.location = "https://mySite.com/myController/myFunction";

After (working):
Code:
window.location = "/myController/myFunction";