【发布时间】:2016-03-31 09:48:03
【问题描述】:
我将 OTP(一次性密码)会话用作 $this->session->set_userdata('otp')。我想将此会话的到期时间设置为 5 分钟(300 秒)。对于我的代码中的所有其他会话,我希望到期时间为正常会话时间。这个怎么做?
【问题讨论】:
-
你不能使用 cookie 或 codeigniter
flash_data吗? -
我的项目使用的是 codeigniter 2.2,所以 flash_data 是不可能的
-
@SankarV 不,flash_data 只存在 1 个请求,所以这不是一个选项。但是,您可以做的是存储添加会话的时间,然后检查令牌是否已过期。 Codeigniter 本身并没有为此提供库。
-
@Jordy .. 哎呀.. 对不起.. 我的意思是
tempdata。我们不能使用 codeignitertempdata吗? -
@Thedeveloper 如果您不想更改任何内容,可以尝试使用数据库。
store into database with timestamp on user input check that **current timestamp > timestamp + 5 minutes** then give error message and if not let user pass that condition希望你能得到我... :)
标签: php codeigniter session codeigniter-2