Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Session Cookies Only for Specific Routes

I'm using Connect.js and the connect-session module for managing session cookies. I noticed that Connect sets a session cookie on all routes except static files. The problem is that I process some static files like JS and CSS files before I send them so I can't use Connect's built-in static server, which means that connect-session sets a session cookie for these files. Since these files will be included on external sites, I don't want them to send cookies with them.

Is it possible to set session cookies only for specific routes?

like image 321
Kevin McTigue Avatar asked Oct 19 '11 18:10

Kevin McTigue


People also ask

What is a session cookie used for?

The session cookie is a server-specific cookie that cannot be passed to any machine other than the one that generated the cookie. The session cookie allows the browser to re-identify itself to the single, unique server to which the client had previously authenticated.

Should I Always allow session cookies?

Should I always allow session cookies? Session cookies are essential for a website's functionalities or for it to deliver a service that it intends to. They are also exempt from consent requirements under privacy regulations like the GDPR.

Are cookies per session?

Per-session (sessional) cookies are stored in memory and are only available during an active session, in other words, while you are on the website. Per-session cookies do not permanently record data and are not stored on your computer's hard drive.

Is session independent of cookies by default?

By default, SessionID values are stored in a cookie. However, you can also configure the application to store the SessionID value in the URL for a "cookieless" session.


1 Answers

if you are using express,you can put app.use(express.static(path.join(__dirname, 'public'))); before app.use(express.session());.

like image 170
little bitter gourd Avatar answered Sep 22 '22 05:09

little bitter gourd