mozilla / node-client-sessions

secure sessions stored in cookies
Mozilla Public License 2.0
759 stars 104 forks source link

How can I delete certain information after a request has been sent to the server. #116

Closed illcrx closed 7 years ago

illcrx commented 7 years ago

When a user makes a request I am going to store the whole mongo document on their browser, then recall that upon the next request they send back to use if I need to. However I dont want to overload the browser. Is there a way to delete data after a request is sent to the server without deleting all of the session data? From the docs it looks like the session has to be timed, however I cannot tell if a user is going to be on the same page for a few seconds or days.

seanmonstar commented 7 years ago

You can just delete a property from the session, and that will send an updated cookie header.

However, I'd like to advise that depending on the size of this mongo document, it may not be wise to be sending it in a Set-Cookie header. The client will be resubmitting the entire document to the server with every request, and every time you make a tiny change in that document, the server will resend the entrire thing in a new Set-Cookie header.

illcrx commented 7 years ago

Fair assessment I could just send what I need then, thanks!