Cookie not set
See original GitHub issueHi, When calling in BROWSER http://localhost:3000/membre/identification/setcookie, cookie is set correctly. But when this api url is called by http request from my angular application (http://localhost:4200/home), cookie is not set. I don’t undersand why.
IdentificationController.ts:
...
@Get("/setcookie")
setcookie(@Session() session, @Req() request: Request, @Res() response: Response)
{
session.membre = {}
session.membre.id = 'OK';
session['membre'] = 'AZERTY';
return session;
}
// return {"cookie":{"path":"/","_expires":null,"originalMaxAge":null,"httpOnly":true,"domain":"localhost","sameSite"
:false,"secure":false},"membre":"AZERTY"}
@Get("/getcookie")
getcookie(@Session() session, @Req() request: Request, @Res() response: Response)
{
return {'session': session};
}
// return {"session":{"cookie":{"path":"/","_expires":null,"originalMaxAge":null,"httpOnly":true,"domain":"localhost"
,"sameSite":false,"secure":false}}}
...
app.
expressApp.use(session({
secret: 'cookie_secret',
resave: true,
saveUninitialized: true,
cookie: {
//domain: 'localhost',
sameSite: false,
path: '/',
httpOnly: true,
secure: false,
maxAge: null
}
})); // use session middleware
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
php - Why are my cookies not setting? - Stack Overflow
The problem comes from the fact that setcookie() doesn't set the cookies immediately, it sends the headers so the browser sets the cookies....
Read more >7 Keys to the Mystery of a Missing Cookie - Medium
7 Keys to the Mystery of a Missing Cookie · 1. SameSite attribute Defaults to Lax · 2. withCredentials is not Set to...
Read more >Set-Cookie - HTTP - MDN Web Docs
Controls whether or not a cookie is sent with cross-site requests, providing some protection against cross-site request forgery attacks (CSRF).
Read more >Response cookies not being set · Issue #386 · github/fetch
I'm trying to implement client login using fetch on react. I'm using passport for authentication. The reason I'm using fetch and not regular ......
Read more >Error: "State cookie not set or expired. Maybe you took too ...
Solution. Ensure that cookies are enabled in your browser. Cookies are required by certain connectors for users to authenticate with their API. After...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Web browsers do not allow that to happen for security reasons. For example, if you try to set a cookie on google.com from your site, when you then go to google.com that cookie is not set, because the web browser just ignored it for security reasons. We can only work within the limitations web browsers impose on cookies.
I suppose i should use proxy servers.