How do you update a cookie in PHP?

前端 未结 5 1983
清酒与你
清酒与你 2020-12-30 23:06

If I call setcookie() two times with the same cookie name, I get two cookies created.

How do you update an existing cookie?

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 23:30

    You can update a cookie value using setcookie() function, but you should add '/' in the 4th argument which is the 'path' argument, to prevent creating another cookie with the same name.

    i.e. setcookie('cookie_name', 'cookie_value', $exp_date, '/');

提交回复
热议问题