Set httpOnly and secure on PHPSESSID cookie in PHP

前端 未结 8 1315
鱼传尺愫
鱼传尺愫 2020-12-03 10:09

Whats the recommended way to set httponly and secure flags on the PHPSESSID cookie?

I found http://www.php.net/manual/en/session.configuration.php#ini.session.cookie

8条回答
  •  长情又很酷
    2020-12-03 10:44

    A more elegant solution since PHP >=7.0

    session_start(['cookie_lifetime' => 43200,'cookie_secure' => true,'cookie_httponly' => true]);
    

    session_start

    session_start options

提交回复
热议问题