Giter Site home page Giter Site logo

Comments (6)

Fishrock123 avatar Fishrock123 commented on May 8, 2024

Not sure if I should suggest the pull request for this feature. Is this repository about only cookie-based sessions?

No, that is cookie-sessions. This is a generic session middleware that has to be hooked into a session store. (please don't use memory store, for your own good.)

.. so, you can make a PR if you'd like. :)

from session.

dougwilson avatar dougwilson commented on May 8, 2024

Well, this is a generic one got web requests using Cookies. This has been brought up a few times and the answer is it just don't fit in.

there are some restrictions with fetching them in JavaScript

this module simply hides them from javascript access by default. have you tried the following?

app.use(session({
    secret: 'keyboard cat'
  , cookie: { httpOnly: false } // allow JavaScript access to cookie
}))

from session.

alexey-detr avatar alexey-detr commented on May 8, 2024

Yes, tried this. But removing httpOnly mark is not enough when using AJAX requests. I still had problems with xhr.getResponseHeader('Set-Cookie'). As I can see, it's restricted by latest XMLHttpRequest Level 1 draft

Returns the header field value from the response of which the field name matches header, unless the field name is Set-Cookie or Set-Cookie2.

from session.

dougwilson avatar dougwilson commented on May 8, 2024

@detonator anything that is in Set-Cookie will automatically become part of document.cookie after the request completes, no?

from session.

alexey-detr avatar alexey-detr commented on May 8, 2024

@dougwilson nope, document.cookie returns cookies for current domain. Some of my requests are performed via CORS with pre-flight. So the only place where I can fetch session ID is in the AJAX request callback.

from session.

dougwilson avatar dougwilson commented on May 8, 2024

Oh, you didn't mention CORS :) Yes, you cannot access cookies from another domain no matter what (also, this is the reason you cannot read Set-Cookie headers ;) ). Send your PR and I can mull it over. I see you just have a fork, so it should be easy, haha.

from session.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.