doumie7914 2015-06-11 08:12
浏览 52

与导致会话注销codeigniter的ajax请求相关的问题

In my current application, I am making a lot of ajax requests to the backend.

Codeigniter version being used is 2.1.4.

So after a time the session logs out, I think due to session changing and an ajax request still making request using the past token.

With codeigniiter version 2.2.1, I see a fix for "Fixed a bug in the Session Library where session ID regeneration occurred during AJAX requests.". Since I have a expiration time of 2 hours and I have a single js page application with no page reload, with version 2.2.1 do I need to make a ajax request to change the token in background every 2 hour while no other ajax requests are happening.

Thanks.

  • 写回答

2条回答 默认 最新

  • douzao9845 2015-06-11 08:37
    关注

    In config.php check and update below lines for session settings.

    /*
    |--------------------------------------------------------------------------
    | Session Variables
    |--------------------------------------------------------------------------
    |
    | 'sess_cookie_name'        = the name you want for the cookie
    | 'sess_expiration'         = the number of SECONDS you want the session to last.
    |   by default sessions last 7200 seconds (two hours).  Set to zero for no expiration.
    | 'sess_expire_on_close'    = Whether to cause the session to expire automatically
    |   when the browser window is closed
    | 'sess_encrypt_cookie'     = Whether to encrypt the cookie
    | 'sess_use_database'       = Whether to save the session data to a database
    | 'sess_table_name'         = The name of the session database table
    | 'sess_match_ip'           = Whether to match the user's IP address when reading the session data
    | 'sess_match_useragent'    = Whether to match the User Agent when reading the session data
    | 'sess_time_to_update'     = how many seconds between CI refreshing Session Information
    |
    */
    $config['sess_cookie_name']     = 'ci_session';
    $config['sess_expiration']      = 7200;
    $config['sess_expire_on_close'] = FALSE;
    $config['sess_encrypt_cookie']  = FALSE;
    $config['sess_use_database']    = FALSE;
    $config['sess_table_name']      = 'ci_sessions';
    $config['sess_match_ip']        = FALSE;
    $config['sess_match_useragent'] = TRUE;
    $config['sess_time_to_update']  = 300;
    
    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题