Closed Rich-F-G-Mills closed 2 years ago
@Rich-F-G-Mills Definitely unset
would be a welcome addition. I find myself often setting key values to an empty string as a workaround.
@ademar Thank you for confirming... My initial concern was that I was just missing the point!
I have made a proposed code change (heavily inspired by the response to my SO question).
It can be found: https://github.com/Rich-F-G-Mills/suave/commit/34834ddc298aa9c3288a7607c3e46bdc46471b9d
This is my first time contributing to OSS so I'm bracing for harsh feedback!
It looks good, the only change I would ask is to pass the cookie lifetime as a parameter to remove
the same way set
does when it calls write
; otherwise calling unset
may change the lifetime of the session cookie.
Then send a pull request over.
@ademar Thank you for looking it over.
This has now been done and a PR created. Note that I have also added another try
block to capture any exception raised when re-serialising the new map
.
The Suave documentation on sessions shows an example of how a key can be added/fetched from the session state (via
StateStore
)The current implementation of
StateStore
provides methods forget
andset
.Would there be any appetite to extend this for an
unset
method?This is related to a question I asked on StackOverflow where another user has provided a work around.