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
12
votes
2 answers

How do I set a cookie with a (ruby) rack middleware component?

I'm writing a rack middleware component for a rails app that will need to conditionally set cookies. I am currently trying to figure out to set cookies. From googling around it seems like this should work: class RackApp def initialize(app) …
phaedryx
  • 2,024
  • 3
  • 16
  • 24
11
votes
3 answers

Set-Cookie was blocked because its Domain attribute was invalid with regards to the current host url

I have a react frontend with domain sambat.io, deployed to Vercel (Zeit) and a Node API deployed to Heroku with this domain https://safe-ridge-68566.herokuapp.com/ and cookie setup like this: res.cookie('something',…
herlambang
  • 158
  • 1
  • 1
  • 7
10
votes
4 answers

jquery cookie set value to boolean true

I am using this jquery.cookie plugin and I need to set value to TRUE or NULL/FALSE. I am trying to do it like this: $.cookie('ff', true, { expires: 30, path: '/' }); but it sets the value to string and not boolean. Any ways of fixing this?
Alex
  • 7,538
  • 23
  • 84
  • 152
10
votes
3 answers

Why isn't my "Set-Cookie" response header getting translated into an actual cookie?

I'm using Java 8, Wildfly 11, Spring 4 and Apache 2.4. I have this Java code that sets the session cookie cookie = new Cookie(SESSION_ID_KEY, sessionId); ... final String domain = request.getServerName().indexOf(".") == -1 ? request.getServerName()…
Dave
  • 15,639
  • 133
  • 442
  • 830
10
votes
5 answers

How to read/write cookies for local file:/// HTML document?

How can I read/write cookies for local file:/// HTML document using Javascript or jQuery? I tried this one >> function setCookie(c_name, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value =…
Ωmega
  • 42,614
  • 34
  • 134
  • 203
9
votes
2 answers

Cookies not set or sent in request in iOS Safari or Chrome works on all Android and Desktop Browsers

I use a set-cookie header made on the backend to set a secure, http-only cookie on the device. This has worked like a charm on desktop Safari, Chrome, FF, IE etc. This also works on Android Chrome. However, when I tried to run the same exact code…
9
votes
1 answer

Angular 5, httpclient ignores set cookie in post

I'm dealing with HttpClient in Angular 5, the problem is the cookie sent by the server during login process, it seems that Angular is ignoring it because next request with "withCredentials" is not setting it. My package.json .... "@angular/cli":…
UserMan
  • 471
  • 2
  • 10
  • 20
9
votes
2 answers

How to store (and retrieve) a cookie array with Angular cookies

I'm trying to store my cookies with AngularJS as an array to keep the cookie file clean. I'm using the following method: $cookies.put('myCookieArray',{'key1':'value1','key2':'value2'}); Now, when I try to retrieve it using: getmycookiesback =…
Artvader
  • 906
  • 2
  • 15
  • 31
9
votes
1 answer

Node, express.session as middleware does not set cookie

this question is related to NodeJS + Express - Apply session middleware to some routes which I first thought would solve my problem. But it did not. I'm trying to build a site where the first default-page show the user info about the site needing to…
northmoose
  • 139
  • 1
  • 1
  • 6
8
votes
1 answer

Can setcookie in PHP result in multiple "Set-Cookie" headers?

I am debugging an issue with a Magento system. The problem is a duplicated Set-Cookie header, like this: Set-Cookie: flimmit_session=search-0c30086b812519b006aa27ef4f37f15b-24; path=/; domain=.flimmit.com; httponly Set-Cookie:…
The Surrican
  • 29,118
  • 24
  • 122
  • 168
8
votes
1 answer

Chrome ignores Set-Cookie response headers from XMLHttpRequest within extension

I have a background page in a Chrome extension that makes requests to a server. By using Chrome's debugging tools I can see that various Set-Cookie headers are returned. However, subsequent requests do not contain these cookies - Chrome seems to…
8
votes
1 answer

This set-cookie was not stored due to user preference

I have set a cookie from an api and returned it as a response. But the latest version of chrome beta is not letting me to store the cookie. I have also set the SameSite="None" and Secure for considering third party cookies. But this is not getting…
8
votes
4 answers

Set-Cookie in response from server but not stored in storage cookie

I have an issue with my Graphql server and react front-end. When submitting a "signin" mutation, the mutation is handled correctly and data received. The "Set-Cookie" is received in the response headers, but its not stored in the browser…
Stephan Du Toit
  • 789
  • 1
  • 7
  • 19
8
votes
3 answers

Dart - Request GET with cookie

I'm trying to make a get request but I need to put the cookie. Using the curl works: curl -v --cookie "sessionid=asdasdasqqwd" But the function below does not bring anything import 'dart:async'; import 'package:http/http.dart' as…
rafaelcb21
  • 12,422
  • 28
  • 62
  • 86
8
votes
1 answer

TypeError: str.trim is not a function (Request-Promise/Tough-Cookie)

I am having similar problem as discussed here: https://github.com/request/request-promise/issues/183 I am using Request-Promise@4.2.2 and Tough-Cookie@2.3.4 And getting the same error: TypeError: str.trim is not a function I also played around…
1 2
3
79 80