While pairing on a project we found a need to set a default value for a session option and realized that get_session/3 doesn't exist.
This allows us to set a default value when attempting to get_session when the value is nil.
Alternatives
Currently this returns the default value even if the key exists but contains nil.
An alternative implementation would check if the key exists in the session and only return nil if the key does not exist.
Hello!
While pairing on a project we found a need to set a default value for a session option and realized that
get_session/3
doesn't exist. This allows us to set a default value when attempting toget_session
when the value isnil
.Alternatives
Currently this returns the
default
value even if thekey
exists but containsnil
. An alternative implementation would check if thekey
exists in the session and only returnnil
if the key does not exist.Let us know what you think, thanks!