Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to overwrite existing Cookie with new value in PHP?

I have been searching on how to overwrite a certain cookies value like for example in user's information. how can I call the cookie back to the client matched on the user's input. for the cookie to change its value?

like image 515
Webdev Avatar asked Feb 21 '23 15:02

Webdev


1 Answers

You can only overwrite cookies that you have access to modify. If you are setting a cookie yourself with setcookie() the same functionality will overwrite that cookie.

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

like image 120
Steve Buzonas Avatar answered Mar 04 '23 04:03

Steve Buzonas