CodeIgniter Forums
CodeIgniter4 - xhr/ajax request refreshing session expire time - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: CodeIgniter4 - xhr/ajax request refreshing session expire time (/showthread.php?tid=70895)



CodeIgniter4 - xhr/ajax request refreshing session expire time - Przem4S - 06-14-2018

Hello,

I have problem with session expire parameter, when sending Ajax to server expire time is refreshed - so session never expire.
Like screen (look at 'expires' parameter of cookie):

[Image: qnMRbQk.png]


RE: CodeIgniter4 - xhr/ajax request refreshing session expire time - InsiteFX - 06-15-2018

See HTTP incoming request isAjax();

Also you should do a session write close before executing Ajax.


RE: CodeIgniter4 - xhr/ajax request refreshing session expire time - Przem4S - 06-15-2018

Hi,

Yes, isAjax() returns true.

In steps:

1. I create session in BaseController.
2. Display some view with jQuery.
3. This view sends Ajax in 10 secs interval.
4. Effect = every interval runs \CodeIgniter\Session\Session->setCookie method and then rewrite expiration time with new (mayby this is bug?).

Now I find solution for this, override this method by own:
[Image: eZ69hkn.png]


RE: CodeIgniter4 - xhr/ajax request refreshing session expire time - InsiteFX - 06-15-2018

If it is a bug then I would report it on GitHub.


RE: CodeIgniter4 - xhr/ajax request refreshing session expire time - Przem4S - 06-15-2018

Yes, I think it is, it should be checking current session expire time and set it or not changing session cookie, other cookie functionality work fine, but expire time refreshing.

EDIT: Report on github created.