expressjs / cookie-parser

Parse HTTP request cookies
MIT License
1.96k stars 220 forks source link

My cookies automatically expire after 30 minutes #83

Closed jackmatrix75 closed 3 years ago

jackmatrix75 commented 3 years ago

I am using cookie-parser for express but I am confused by the way my cookies behave :

I set my cookie to expires after 1 hour but it expires always after 30 minutes

res.cookie('mycookie', 'value',{expire: Date.now() + 3600000,secure:true,httpOnly:true});

I also tried

res.cookie('mycookie','value',{maxAge:3600000,secure:true,httpOnly:true});

whithout success. My cookie always expires after 30 minutes, even when I set 5 minutes , it expires 30 minutes later. I really can't figure out what's wrong.

Thanks for helping

dougwilson commented 3 years ago

So there are a couple things. 1. This module has nothing to do with setting the cookies and it just provides to you what the web browser sent. It would only be some kind of issue with this module if you can show a request where there is a cookie header and the value did not end up in req.cookies. And 2. unfortunately this isn't debuggable on the server side, only within the web browser. Really once you have the one hour cookie set, you should consult the web browser's documentation you are using to see what the browser has the cookie set to and see if it expired, the reason for that.