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

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

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题