Re: cookie management
| From: | Christoph M. Becker | Date: | Mon, 19 Feb 2018 14:24:22 +0000 |
| Subject: | Re: cookie management | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-326382@lists.php.net to get a copy of this message | ||
On 16.02.2018 at 22:04, Jeffry Killen wrote:
> I am working on a project that has to manage
> cookies both by php and by javascript.
>
> A cookie is set for a user.
>
> Now if the same user opens a new window in the browser and navigates to the same page
> that set the cookie in the first window, how will the server be able to differentiate, assuming
> the cookie has the same name, set in the same client in both opened windows? The second
> would overwrite the first if the values are different, right?
Yes.
> I am thinking of cookie arrays but I am not sure that would be the solution.
You can store an *arbitrary* string in a cookie (note that there are
usually rather tight limits regarding the size of all cookies of a
domain, though). You could store a JSON string inside the cookie, or
use multiple cookies. However, that wouldn't appear to solve your issue.
It seems to me that the problem is: "how will the server be able to
differentiate". Why should the server differentiate which tab made the
request, at all?
--
Christoph M. Becker