Mulligan
Mulligan

Reputation: 81

Setcookie domain parameter handling

I would like to know with a possible detailed way how the "setcookie" domain parameter is handled. Let's take the following example:

setcookie("TestCookie", $value, time()+3600, "/~rasmus/", "www.example.com", 1); 

I'm wondering which scenario is taken place:

  1. The server decides whether or not to send to the client info to set the cookie "TestCookie"
  2. The server sends info to the client to set the cookie along with info to set the cookie only for "www.example.com" domain (and it's subdomains) requests. Then the browser upon user request decides to set & send the cookie or not.

So i'm asking again on which side the decision is given? Server or client?

Upvotes: 1

Views: 168

Answers (1)

Martin Prikryl
Martin Prikryl

Reputation: 202118

On client-side.

The setcookie does not do anything smart. It just takes its arguments, formats and outputs the Set-Cookie HTTP header (according to RFC 6265).

You can use any web browser developer tools to see HTTP headers (including cookie headers) in and out. It would help you understand, how it works.

Upvotes: 1

Related Questions