GithubHelp home page GithubHelp logo

use proxies for session data about session HOT 17 OPEN

expressjs avatar expressjs commented on May 22, 2024
use proxies for session data

from session.

Comments (17)

jonathanong avatar jonathanong commented on May 22, 2024

Meh I would just wait for proxies. This isn't really intuitive

from session.

MichaelCereda avatar MichaelCereda commented on May 22, 2024

Citating the example in README.md, you can add user-specific properties in this way

var sess = req.session;
if (sess.views) {
    sess.views++;
} else {
  sess.views = 1;
}

you can even store nested objects

from session.

Fishrock123 avatar Fishrock123 commented on May 22, 2024

@MichaelCereda This a feature proposal, not a question. ;)

from session.

MichaelCereda avatar MichaelCereda commented on May 22, 2024

Yes, I know that, but I'm guessing why it should be necessary?
you can already interact with session using getter/setter.

from session.

dougwilson avatar dougwilson commented on May 22, 2024

@MichaelCereda to know if the session was modified to write it back to the store.

from session.

MichaelCereda avatar MichaelCereda commented on May 22, 2024

ok so you need to fire an event when session "data" is changed...isn't it?

from session.

colelawrence avatar colelawrence commented on May 22, 2024

In order to implement this, we would probably need to have it on a different property of req in order to not change the way it works currently. If someone wants to do something like this they may be better off looking into another library.

BUT, if it were a configuration option like asStore: true and completely change the behaviour of the req.session object, then it would be okay and non-breaking. Then again all that extra code for event firing and storing might increase the code-base by more than twice LoC, so we might as well have a different version that behaves like that.

from session.

dougwilson avatar dougwilson commented on May 22, 2024

@zombiehippie this would just be a major version bump, i.e. breaking. Also, there is no event firing here, it's just keeping a dirty flag.

from session.

colelawrence avatar colelawrence commented on May 22, 2024

this would just be a major version bump, i.e. breaking

@dougwilson I think you are right.

from session.

MichaelCereda avatar MichaelCereda commented on May 22, 2024

Yes, a major release will be a good thing and allows to implement other breaking feature requests.

from session.

Fishrock123 avatar Fishrock123 commented on May 22, 2024

I had already assigned this to a 2.0.0 milestone. :)

from session.

jonathanong avatar jonathanong commented on May 22, 2024

i don't think this is worth it unless you allow atomic updates on each .get(). here's how i think sessions are supposed to look like: https://github.com/aheckmann/koa-mongodb-session

from session.

colelawrence avatar colelawrence commented on May 22, 2024

Thank you for the example, it should help us understand your suggestions.
On Jun 17, 2014 3:01 AM, "Jonathan Ong" [email protected] wrote:

i don't think this is worth it unless you allow atomic updates on each
.get(). here's what i think is how sessions are supposed to look like:
https://github.com/aheckmann/koa-mongodb-session


Reply to this email directly or view it on GitHub
#46 (comment).

from session.

ilanbiala avatar ilanbiala commented on May 22, 2024

Is this still being pursued for 2.0.0? I also don't see a 2.0.0 branch, but there is a milestone. Any timeline?

from session.

Fishrock123 avatar Fishrock123 commented on May 22, 2024

No real idea, sorry. :/

from session.

Fishrock123 avatar Fishrock123 commented on May 22, 2024

Proxies are in Node v6, so this should actually be possible now.

from session.

aks- avatar aks- commented on May 22, 2024

I'd love to play with this. Or push a branch that does something interesting and make a PR and discuss it.

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.