Skip to content
This repository has been archived by the owner on Sep 5, 2024. It is now read-only.

subdomain #108

Open
mvtcode opened this issue Jan 1, 2016 · 3 comments
Open

subdomain #108

mvtcode opened this issue Jan 1, 2016 · 3 comments

Comments

@mvtcode
Copy link

mvtcode commented Jan 1, 2016

I want subdomain can have access to session, I have configured like?

eg:
I create session at domain abc.com, and I want to access the session in domain name 1.abc.com or 2.abc.com (* .abc.com)

thank!

@compoundf
Copy link

I'd also be interested in this -- I'm trying to find an answer for this exact situation as well.

@ghost
Copy link

ghost commented Aug 27, 2016

Subdomains generally do not exchange cookies. Subdomains are similar but different domains and are treated as such.

While it's probably hackable, this isn't an issue node-client-sessions's code can solve.

@gswalden
Copy link

gswalden commented Jan 9, 2017

Untested, but because this depends on cookies, you should be able to pass the domain option to set a domain-wide cookie (ex. .github.com instead of subdomain.github.com).

Untested proposal:

app.use(sessions({
  cookieName: 'mySession', // cookie name dictates the key name added to the request object
  secret: 'blargadeeblargblarg', // should be a large unguessable string
  duration: 24 * 60 * 60 * 1000, // how long the session will stay valid in ms
  cookie: {
    domain: '.github.com',
    path: '/api', // cookie will only be sent to requests under '/api'
    maxAge: 60000, // duration of the cookie in milliseconds, defaults to duration above
    ephemeral: false, // when true, cookie expires when the browser closes
    httpOnly: true, // when true, cookie is not accessible from javascript
    secure: false // when true, cookie will only be sent over SSL. use key 'secureProxy' instead if you handle SSL not in your node process
  }
}));

Update: #93 appears to confirm

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants