How to overwrite an existing cookie with a new value in PHP?

I was looking for how to overwrite a specific cookie value, for example in user information. how can I call a cookie back to a client consistent with user input. for a cookie to change its value?

+4
source share
1 answer

You can only overwrite cookies that you have access to change. If you set the cookie yourself using setcookie() , then the same function will overwrite this cookie.

Cookies must be modified before any data is sent to the browser. The browser identifies the cookie and saves it based on the headers sent from the server to the browser. The HTTP protocol will not accept header elements during body transfer.

+7
source

Source: https://habr.com/ru/post/1394534/


All Articles