Comments (17)
Sometimes I wonder how is it possible these modules get downloaded 70K times a month and their documentation and support is so limited.
I might be used to other platforms where things are different... but Node never stops surprising me.
from cookie-session.
Did you provide any options at your middleware construction time?
I did as far as I know:
app.use(cookieSession({
maxAge: 3 * 1000, //20*60*1000, //20 mins
httpOnly: true,
secure: true,
secureProxy: true,
keys: ['key1', 'key2']
}));
app.use(function(req,res,next ){
console.log(req.session.user); //user data
console.log(req.sessionOptions); //empty array
req.sessionOptions.maxAge: 4000;
console.log(req.sessionOptions); // (maxAge: 4000)
return next();
});
I managed to solve the problem with the renew of the session thanks to this answer in stackoverflow.
Although I'm not quite sure yet why updating a fake
session has anything to do with the renew of session.user
maxAge.
from cookie-session.
Isn't this like a pretty basic feature of any session component?
I saw it was marked as a "question" but... isn't there any simple answer for it?
I would like the sessions to be renewed on every page load (or ajax call). That's how they usually work anywhere.
I've tried doing this, but without success:
app.use(function(req,res,next ){
req.sessionOptions.maxAge = 3000;
return next();
});
from cookie-session.
Hi, I'm sorry, but I'm only maintaining this module and did not write it. I don't know enough about it to answer and have not had the time to investigate. I was hoping someone else could answer. I marked it as a question because I assumed it was possible to do what you ask.
If you're saying instead that it's not possible, I can change the label to a feature request instead.
from cookie-session.
If you're saying instead that it's not possible, I can change the label to a feature request instead.
Nop, just asking as I believe documentation doesn't provide the necessary information.
from cookie-session.
Nop, just asking as I believe documentation doesn't provide the necessary information.
Gotcha, that's what I thought and why I labeled this as a question :) The answer from me is "I don't know", which is why I just labeled it and didn't provide an answer. I'll try to take a look into it sometime in the next few weeks if no one else stops by with an answer :)
from cookie-session.
req.sessionOptions
seems to be always empty unless I set an option.
app.use(function(req,res,next ){
console.log(req.session.user); //user data
console.log(req.sessionOptions); //empty array
req.sessionOptions.maxAge: 4000;
console.log(req.sessionOptions); // (maxAge: 4000)
});
Documentation says:
These options are a shallow clone of what was provided at middleware construction and can be altered to change cookie setting behavior on a per-request basis.
from cookie-session.
Hi! Yes, the documentation says:
These options are a shallow clone of what was provided at middleware construction
Did you provide any options at your middleware construction time? It just contains whatever you gave to the module's constructor. Can you show a full app that reproduces?
from cookie-session.
Hmm. Perhaps the issue is with your console.log(req.sessionOptions)
statement? What happens if you replace both console.log(req.sessionOptions)
s with console.log(req.sessionOptions.maxAge)
in your program above? And what if you replace both with console.log(JSON.stringify(req.sessionOptions))
?
from cookie-session.
Interestingly console.log(req.sessionOptions.maxAge)
shows the original value.
Not console.log(req.sessionOptions)
or console.log(JSON.stringify(req.sessionOptions))
from cookie-session.
Gotcha, that's what I was expecting from how Node.js works. It sounds like everything is working just fine, then to me. Do you have some kind of use-case in your application to do a console.log(req.sessionOptions)
?
from cookie-session.
Gotcha, that's what I was expecting from how Node.js works.
Why is it?
from cookie-session.
Why is it?
$ node -e 'obj={a:1};console.log(Object.create(obj));console.log(obj.a)'
{}
1
from cookie-session.
The exact same command in Firefox is the following:
> obj={a:1};console.log(Object.create(obj));console.log(obj.a)
Object { a=1 }
1
from cookie-session.
The referenced PR (#49) worked for me - once I added the missing call to next()
:-)
from cookie-session.
I brought up the possibility of adding some method to wrap and standardize the process mentioned in #49 if there is a consensus that doing so make sense.
from cookie-session.
I think this question was answered, and there is a PR even that would add an example to the README.
from cookie-session.
Related Issues (20)
- Session does not get stored if keys is not an array HOT 3
- What am I doing wrong? [question] HOT 1
- Clearing session does not remove cookies HOT 8
- Generating unique session.sig after logout/login HOT 3
- Use cookie-session as non middleware HOT 2
- Not working with axios (chrome) but working with Postman HOT 10
- Document: Ambiguity in Signature Documentation HOT 4
- sameSite no longer defaults to 'None' when undefined HOT 4
- session cookie value is exceedingly long and fails Set-Cookie with invalid syntax HOT 2
- secureProxy option to be able to use with non-Express servers behind SSL proxy HOT 1
- Suggestion: a custom name instead of req.session HOT 2
- Update dependency from [email protected] to [email protected] HOT 3
- Is there a risk when someone modifies the userId in the cookie? HOT 2
- Session cookie not sent over from server when using Firefox HOT 4
- Problem using with passport 0.6.0: session.regenerate is not a function HOT 7
- flag Priority=High
- encrypt cookies
- The link to a list of browser cookie limits is dead
- Larger cookies with compression
- cookie options not being set
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cookie-session.