You can only change the cookie domain on the client or set it on the server . Once the cookie is set, the path and domain information for it exists only on the client. Therefore, existing cookies cannot change their domain on the server because this information is not sent by the client to the server.
For example, if there is a cookie on your local computer:
MYCOOKIE:123, domain:www.test.com, path:/
The server will only receive:
MYCOOKIE:123
on server. Why is the path and domain not sent? Since the browser stores this information on the client and does not interfere with sending it, because it sends this cookie only to your server if the page is on www.test.com and along the path / .
, , cookie. , - , : , cookie , . , Apache mod_headers:
<IfModule mod_headers.c>
Header edit Set-Cookie (.*)(domain=.company.com;)(.*) $1 domain=app.company.com; $2
</IfModule>
mod_headers cookie, , , :
<IfModule mod_headers.c>
RequestHeader edit Cookie "OLD_COOKIE=([0-9a-zA-Z\-]*);" "NEW_COOKIE_NAME=$1;"
</IfModule>
cookie, .