How to handle login when session cakephp time out


In my core.php config I've set the session like this

Configure::write('Session', array(
    'defaults'          => 'php',
    'cookie'            => 'mawar',
    'timeout'           => 1, 
    'autoRegenerate'    => true 

and It's working as well, but The problem is when the session expired user need to re-login, and before session time out there is request in ajax, because user is not in login condition so ajax not working and show error 403 - Forbidden

My question is how to give the better solution for user so user be able to continue input form data which already input

whether give a simple modal form login while session expired? or you have more better solution for this case

now I've already tried to read when condition session has expired in app controller with this code

if($this->Auth->user('id')) {// if the user has been logged out because the session has time out
 if ($this->request->isAjax()){ // and if the request ajax
            // here I want to open modal / simple form login

And I'm stuck, I'm so glad for your responses

thanks in advance

Show source
| cakephp   | session   | cakephp-2.0   | cookies   | modal-dialog   2017-01-06 05:01 1 Answers

Answers to How to handle login when session cakephp time out ( 1 )

  1. 2017-01-06 06:01

    A good solution to your problem would be setting the session expiry time yourself or "remember me" feature.

    You can set the session expiry time as you like. Check this out.

    Creating a "remember me" feature in login will also be helpful for your program as it will store the user credentials in the browser cookie and the user will be logged in as per requirement. You can check this for "remember me" details.

Leave a reply to - How to handle login when session cakephp time out

◀ Go back