dqf35839 2012-05-02 15:51
浏览 49
已采纳

php延长会话到期时间

So I have looked about on here and web in general and cant find anything for exactly what I need. I have seen a bunch of posts about forcing it to expire after an exact amount of time, but I just want to extend my session lifetime.

I am not sure if it is based on inactivity, or just a set length of time, but it seems that it will lose any session data stored. For example cart data on a shopping basket.

I just want to be able to keep the product data in there for more than what seems like 30 mins, so I have the below included at the top of every script, but it definitely does not last 10 hours.

ini_set("session.cookie_lifetime","36000");
ini_set("session.gc_maxlifetime","36000");

session_start();

I was under the impression that sessions expired when the browser closes, and cookies expire based on time, I dont use cookies, just sessions.

So my question, how do I extend the life of my session?

  • 写回答

1条回答 默认 最新

  • dongwen7730 2012-05-02 15:55
    关注

    If you want a longer session, you may want to consider using cookies (for safe variables only! Never store unencrypted private information in a cookie!).

    Assuming the user will want to view his shopping cart at a later time, your best options are:

    1. Enforce account registeration, and save the shopping cart in a database for each user.
    2. Use a cookie to store the shopping cart locally on the user's machine.

    Do note that some users may disable cookies, so display a big fat warning that your site will fail if cookies are not enabled.

    See Teh Manual

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向