PHP Sessions expiry time - keeping session alive for a specific number of minutes/hours/days

后端 未结 2 863
庸人自扰
庸人自扰 2020-12-19 07:24

I have a site that creates a Session for shopping carts.

$_SESSION[\'cart\']=array();

It seems as if the server automatically kills the ses

2条回答
  •  情深已故
    2020-12-19 07:48

    set a cookie and change in you config that the session use cookies

    session_start();
    set_cookie("PHPSESSID", session_id(), time() + 3600 * 2);
    

    this keep alive your session for 2 hours

提交回复
热议问题