Questions tagged [setcookie]

The setcookie function sends an HTTP cookie to a client.

setcookie() defines a cookie to be sent along with the rest of the HTTP headers. Like other headers, cookies must be sent before any output from your script (this is a protocol restriction). This requires that you place calls to this function prior to any output, including <html> and <head> tags as well as any whitespace.

1196 questions
19
votes
1 answer

Why does Chrome ignore Set-Cookie header?

Chrome has a long history of ignoring Set-Cookie header. Some of these reasons have been termed bugs and fixed, others are persistent. None of them are easy to find in documentation. Set-Cookie not allowed in 302 redirects Set-Cookie not allowed if…
Andrew Johnson
  • 3,078
  • 1
  • 18
  • 24
19
votes
4 answers

Android Volley, duplicate Set-Cookie is overridden

Trying to use Volley lib as a network wrapper for my android application. I have a connection up and running, but the problem is that every time there is multiple "Set-Cookie" headers in the response Volley uses Map that cannot have duplicate keys,…
RompaP
  • 193
  • 1
  • 5
19
votes
3 answers

Why does PHP replace pluses with spaces in $_COOKIE?

So from my understanding of PHP and cookies, if I use the setcookie() function, then I get a cookie that is automatically url encoded. And when I go to the $_COOKIE array, I should get the cookie back, automatically url decoded. Problem is, it…
user1630830
  • 307
  • 2
  • 10
18
votes
1 answer

xmlhttprequest and set-cookie & cookie

I think I misunderstood the management of cookies with xmlhttprequest. I have a server that responds to the XMLHttpRequest made in javascript. My server returns Allow-Control-Access-Origin, Access-Control-Allow-Headers, Access-Control-Expose-Headers…
Kalamarico
  • 5,466
  • 22
  • 53
  • 70
17
votes
2 answers

What is/are the actual practical difference/s in functioning of the built-in functions setcookie() and setrawcookie() in PHP?

I'm learning one of the most important concept of Cookies in PHP in detail. While studying Cookies I come to know that "The value of the cookie is automatically URLencoded when sending the cookie, and automatically decoded when received (to prevent…
PHPLover
  • 1
  • 51
  • 158
  • 311
15
votes
3 answers

Designing a secure auto login cookie system in PHP

I want to have an auto login option check for a user. Basically that means a cookie will be stored on the client side. Now the question is, how do I make it secure so the cookie will can not be spoofed/modified. One of my friends suggest having a db…
CodeCrack
  • 5,253
  • 11
  • 44
  • 72
15
votes
3 answers

Cannot remove a cookie - Firefox rejecting cookies from the past

I'm losing my mind here - I'm looking into an issue where some signout functionality in an application I have isn't working because the authentication cookie is not being cleared. The thing is that our "signout" endpoint does include the appropriate…
Sean
  • 1,698
  • 2
  • 16
  • 22
14
votes
1 answer

What does Priority=High mean in the Set-Cookie header?

I've been looking at Chrome's traffic in Fiddler, and I found something that I feel I don't understand: Set-Cookie: GAPS=1:ZYBtVMzURzU2umKMxZThJ2lVPxy3Hg:SvHhlG2k1Vy5pnA0;Path=/;Expires=Wed, 04-Nov-2015 20:44:37 GMT;Secure;HttpOnly;Priority=High I…
Arsen Zahray
  • 24,367
  • 48
  • 131
  • 224
14
votes
7 answers

PHP session or cookie

What's best way to keep user logged on a PHP-powered site until he closes his browser? The first and the most popular way is to go with $_SESSION. The second is to pass zero as the third argument of setcookie function: setcookie(name, value, 0,…
treng
  • 1,665
  • 3
  • 15
  • 22
13
votes
7 answers

How to retrieve cookie value in CodeIgniter?

I can print the session values in codeigniter by print_r($this->session->userdata); How can I print the cookies in codeigniter? I have just set a cookie: $cookie = array( 'name' => 'test_cookie', 'value' => 'test', …
Roman
  • 3,764
  • 21
  • 52
  • 71
12
votes
2 answers

Samesite cookie but allow specific domain

I would like to secure my cookies using SameSite=strict. But is there a way to allow it to be accessed by few domains alone?
JC Raja
  • 5,597
  • 2
  • 18
  • 10
12
votes
2 answers

PHP Curl and setcookie problem

I have a curl script that acts as proxy between client and main server. ...... $field_array= array( 'Accept' => 'HTTP_ACCEPT', 'Accept-Charset' => 'HTTP_ACCEPT_CHARSET', 'Accept-Encoding' => 'HTTP_ACCEPT_ENCODING', …
tanon
  • 133
  • 1
  • 2
  • 6
12
votes
2 answers

Sending cookie with request from subdomain

We have the following configuration: testing.parentdomain.com When you access this domain and create a basket we create a cookie stored for the basket value. The cookie domain is set to .testing.parentdomain.com, it is Httponly and has a path of…
StuartM
  • 6,743
  • 18
  • 84
  • 160
12
votes
1 answer

I can't set cookie on localhost

I'm using NodeJS with the Express framework with the cookie-parser middleware on localhost:3333. My frontend is served by react dev server on localhost:3000. This is my first attempt at anything to do with cookies. Here are the options i set for my…
12
votes
4 answers

How to set Secure attribute to Set-cookie in Nginx through nginx.conf file

I am new to Nginx server. recently started working nginx project. I have task to set security headers through nginx.conf file. I set some header correctly but not able to set for Set-cookie. My requirement is, in response header Set-Cookie should…
1
2
3
79 80