dpndp64206 2014-12-14 23:29
浏览 45

Codeigniter iOS Web App会话未保存

I have set my codeigniter website to be a web app using Apples documentation. https://developer.apple.com/library/ios/documentation/AppleApplications/Reference/SafariWebContent/ConfiguringWebApplications/ConfiguringWebApplications.html

It works well, but none of my sessions are saving when they switch between apps.

  $this->session->set_userdata('logged_in', true);
  $this->session->set_userdata('id', $data['id']);
  $this->session->set_userdata('role_id', $data['role_id']); 

I found a good article about this but don't know how this would look using codeigniter. Maintaining a PHP session on an iPhone web app

  • 写回答

1条回答 默认 最新

  • duanqiang6501 2014-12-15 10:43
    关注

    Another approach is to use database sessions, please enable it in application/config/config.php by $config['sess_use_database'] = TRUE;

    I mostly use database session because of following fact:

    Note: Cookies can only hold 4KB of data, so be careful not to exceed the capacity. The encryption process in particular produces a longer data string than the original so keep careful track of how much data you are storing.

    Continue; creating table ci_sessions

    CREATE TABLE IF NOT EXISTS  `ci_sessions` (
        session_id varchar(40) DEFAULT '0' NOT NULL,
        ip_address varchar(45) DEFAULT '0' NOT NULL,
        user_agent varchar(120) NOT NULL,
        last_activity int(10) unsigned DEFAULT 0 NOT NULL,
        user_data text NOT NULL,
        PRIMARY KEY (session_id),
        KEY `last_activity_idx` (`last_activity`)
    );
    

    And you are good to go, use the code you provided in question, session is saved in database.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入