Add a clearSessionValue procedure to the next release's API
In
BeijingRelease,
getSessionValue and
setSessionValue were added to the function API. These would call the handlers provided by a session plugin, like
SessionPlugin or
SmartSessionPlugin.
There is no ability to CLEAR a session variable/value though. It would be a good idea to add a
clearSessionValue procedure to the function API. It would simply need to call a
clearSessionValueHandler from a session plugin.
The most recent version of
SmartSessionPlugin already includes a
clearSessionValueHandler. Now it's just waiting for a release of TWiki that has a
clearSessionValue.
--
TedPavlic - 24 Aug 2003
Why not just set it to the empty string?
--
JohnTalintyre - 24 Aug 2003
Setting a session variable to an empty string is not an acceptable definition for a cleared session variable for two reasons:
- It may be desirable for a session variable to hold an empty string, so an empty string cannot be immediately defined as a state where that session variable should be cleared. What if a user WANTS to define a variable like SKIN equal to an empty string for the current session? Perhaps the TWiki preference SKIN is non-empty and the user wants to make the SKIN empty for this session. Clearing the user's session variable would prevent the user from ever being able to store an empty session variable.
- Because a session variable overrides a TWiki preference if it is defined, then leaving a session variable empty still is overriding a possibly non-empty TWiki preference. So, assuming that an empty session variable will have no effect is in error. An empty session variable will mask an underlying TWiki preference.
So it may be necessary for users to want to delete a particular session variable so that the underlying TWiki preference takes over again. It is not acceptable to assume all session variables that are empty should immediately be cleared because TWiki preferences might happen to contain empty strings at the user's request.
So that's why there needs to be two separate operations -- a set as well as a clear.
--
TedPavlic - 25 Aug 2003
I agree with Ted in that we need an orthogonal set of operations for sessions. Overloading what you set the session variable to is an implementation detail that should be masked by a proper api.
On a side note. In many ways I think the continued "cleansing" of the current api to force more orthogonality thruout the twiki code would be a good thing. Im especially encouraged by some of the work on making plugins OO as well which I believe would allow plugin owners to interhit from a base class with a nice orthogonal set of operations rather than needing to delve into the twiki internals...
--
JohnCavanaugh - 25 Aug 2003