Session: Whats the difference between req.session.id and req.sessionID

Created on 1 May 2017  路  6Comments  路  Source: expressjs/session

The two appear to be the same thing. Is there a reason for separate properties?

question

Most helpful comment

But it doesn't say that in the readme:

req.session.id
Each session has a unique ID associated with it. This property will contain the session ID and cannot be modified.

req.sessionID
To get the ID of the loaded session, access the request property req.sessionID. This is simply a read-only value set when a session is loaded/created.

Having two properties with near identical name and just slightly different wording makes it look like they serve different purposes.

Adding a comment:

The req.session.id property was added as an alias for the folks who wanted req.sessionID to be available within the req.session object.

Explains the intention.

All 6 comments

The req.session.id property was added as an alias for the folks who wanted req.sessionID to be available within the req.session object.

@dougwilson Please add the given explanation to the README.md as a comment. :-)

I thought that was already clear in the README. If you have different wording you'd like, please feel free to make a PR with your proposed wording :)

But yes, reading both section it isn't clear (I didn't know before looking when you brought it up).

But it doesn't say that in the readme:

req.session.id
Each session has a unique ID associated with it. This property will contain the session ID and cannot be modified.

req.sessionID
To get the ID of the loaded session, access the request property req.sessionID. This is simply a read-only value set when a session is loaded/created.

Having two properties with near identical name and just slightly different wording makes it look like they serve different purposes.

Adding a comment:

The req.session.id property was added as an alias for the folks who wanted req.sessionID to be available within the req.session object.

Explains the intention.

HI @gajus that's right. Like I said, reading both sections it isn't clear, but didn't know before looking when you brought it up. If you have different wording you'd like, please feel free to make a PR with your proposed wording :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

azfar picture azfar  路  14Comments

shaunwarman picture shaunwarman  路  17Comments

alex55132 picture alex55132  路  22Comments

aheyer picture aheyer  路  15Comments

rukshn picture rukshn  路  20Comments