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
8
votes
1 answer

Safari 11 X-XSRF-TOKEN not updated after refresh

Recently Safari 11 was released on Mac OSX. This update causes problem with our webapplication in combination with XSRF on the header of our reuest. I will try to describe the problem in a logic way. This is how a good situation would look…
Flex
  • 81
  • 6
8
votes
1 answer

Set Cookie with Swift 3

I am struggling to set a cookie using Swift 3 into a WKWebView. I could not find any example using Swift 3 so using Swift - How to set cookie in NSMutableURLRequest as a starting point, this is what I have: let url = URL(string:…
Perry Hoekstra
  • 2,687
  • 3
  • 33
  • 52
8
votes
2 answers

Google Chrome maximum cookie expiry date

I was creating my website when I created a new cookie with this php line : setcookie('subscribed', 'true', time() + 365*24*3600*100, '/', null, false, true); I realised my browser (Google Chrome) refused to get that cookie. When I looked at my…
Farid
  • 215
  • 1
  • 2
  • 8
7
votes
1 answer

My cookies are only available on PHP pages they are set on, is this normal?

I cannot access cookies from any page other than the page they are set on. I looked at print_r($_COOKIE) on different pages and the only common variable between pages is the $_COOKIE['PHPSESSID']. I am developing on a local XAMPP testing server. Is…
Jiminy Cricket
  • 908
  • 1
  • 9
  • 24
7
votes
2 answers

Angular 9 - ngx-cookie-service troubles with path

I'm using ngx-cookie-service package to store some data relevant to my application. I need to save this cookie on the base path '/', so each time I know exactly how to retrieve it. This cookie of mine needs to be updated and when such happens, the…
dc_Bita98
  • 851
  • 2
  • 17
  • 35
7
votes
2 answers

AppSync: How set header in response?

I want to authorize the user through http only cookies. I want to set header in the AppSync response as example "Set-Cookie": "cookie=cookie; HttpOnly" in "Configure the response mapping template" I have $util.toJson($context.result) How can I do…
6
votes
1 answer

Setting a Site Wide Cookie

Here's what I hope is a quick question... I am trying to set a cookie that can be used sitewide. I'm creating a lead generation type site. I want users to fill out a form in order to access exclusive information. Once they fill out the form, they…
Ash
  • 345
  • 1
  • 5
  • 16
6
votes
5 answers

cURL doesn't set a cookie anymore, but why?

My cURL script does not work anymore (so keep in mind it DID work before) on my localhost (so it DOES work on my external host, hence: it might be the server settings): This script worked fine before on my localhost (it still does on my host).…
SuperSpy
  • 1,324
  • 3
  • 13
  • 28
6
votes
0 answers

Angular: How to fix SameSite Cookie issue

My application is on dev-server. It is working in all platforms except Facebook app browser in mobile, although its working on chrome mobile browser. I wasted so many hours and after that I discovered this warning regarding SameSite Cookie: I've…
S M Iftakhairul
  • 1,120
  • 2
  • 19
  • 42
6
votes
2 answers

Not able to set cookie from the express app hosted on Heroku

I have hosted both frontend and backend in Heroku. Frontend - xxxxxx.herokuapp.com (react app) Backend - yyyyyy.herokuapp.com (express) I'm trying to implement Google authentication. After getting the token from Google OAuth2, I'm trying to set…
Manoj Kumar S
  • 634
  • 8
  • 16
6
votes
2 answers

nginx add_header Set-Cookie expires not working

I am trying to set up an nginx server that sets certain parameters in a cookie when hit on a certain location. I have the following configuration that puts the parameters in the cookie but the expiration does not work. This is my…
penguin
  • 61
  • 1
  • 1
  • 2
6
votes
2 answers

How to validate a token without a database?

I have hosted two domains on the same server, domain A and domain B. Domain A will generate the unique access token to the content of domain B. Domain A
user10208455
6
votes
1 answer

Why setCookie() from Puppeteer seems not to work as expected?

The goal I'm trying to achieve is to store the cookies from a website and then to use them in a second moment. Here is the code: To save cookie: let cookie = await page.cookies(); cookie = JSON.stringify(cookie); fs.writeFile("cookie.txt", cookie,…
6
votes
2 answers

Java, let CookieHandler work on only one instance

I don't know how CookieHandler works system wide, I did view the source of CookieHandler but found no more information except the get/set methods. Where do TCP/HTTP connections use instance of CookieHandler, which I set…
user435657
  • 625
  • 2
  • 10
  • 28
6
votes
2 answers

Unit testing cookies in PHP

The default practice for unit testing functionality that relies on session/cookie information is to use an abstraction library. But what if I want to write and unit test this abstraction library? The documentation for the PHP setcookiefunction says…
chiborg
  • 26,978
  • 14
  • 97
  • 115