RejectedSoftware Forums

Sign up

new stuct Session, is there a "check if session's been created"?

I'm updating some pre-0.7.19 code to current vibe, and I had been
relying on "request.session is null" to check whether a session had been
created.

With the new struct-based Session, is there an equivalent way to check
if I have created a session for the current request? Or is there
always an implicit session and I just have to use a custom session
value like "haveIInitedThisSession_Yet" to accomplish the same thing?

Re: new stuct Session, is there a "check if session's been created"?

Am 19.08.2014 02:40, schrieb Nick Sabalausky:

I'm updating some pre-0.7.19 code to current vibe, and I had been
relying on "request.session is null" to check whether a session had been
created.

With the new struct-based Session, is there an equivalent way to check
if I have created a session for the current request? Or is there
always an implicit session and I just have to use a custom session
value like "haveIInitedThisSession_Yet" to accomplish the same thing?

It has a (now also documented) bool opCast() that should make the
struct approach interchangeable in most cases with the class approach.

BTW, if you should ever use the vibe.web.web module (which really can
make the code a lot more concise) and its SessionVar!T, there it does
indeed work with an implicitly (on write) created session, so you need
to have some variable to check if the user is actually logged in.

Re: new stuct Session, is there a "check if session's been created"?

On 8/19/2014 2:44 AM, Sönke Ludwig wrote:

Am 19.08.2014 02:40, schrieb Nick Sabalausky:

I'm updating some pre-0.7.19 code to current vibe, and I had been
relying on "request.session is null" to check whether a session had been
created.

With the new struct-based Session, is there an equivalent way to check
if I have created a session for the current request? Or is there
always an implicit session and I just have to use a custom session
value like "haveIInitedThisSession_Yet" to accomplish the same thing?

It has a (now also documented) bool opCast() that should make the
struct approach interchangeable in most cases with the class approach.

Ahh, yea, I totally missed that. Thanks.

BTW, if you should ever use the vibe.web.web module (which really can
make the code a lot more concise) and its SessionVar!T, there it does
indeed work with an implicitly (on write) created session, so you need
to have some variable to check if the user is actually logged in.

Good to know. I'll look into that more. SessionVar is a relatively new
thing isn't it? I've been sidetracked on other things for awhile so a
lot of my vibe stuff (and vibe knowledge) has bitrotted slightly. Last
thing I remember was that vibe sessions didn't really support typed
data, it was all stings IIRC.

Re: new stuct Session, is there a "check if session's been created"?

Am 19.08.2014 21:43, schrieb Nick Sabalausky:

On 8/19/2014 2:44 AM, Sönke Ludwig wrote:

BTW, if you should ever use the vibe.web.web module (which really can
make the code a lot more concise) and its SessionVar!T, there it does
indeed work with an implicitly (on write) created session, so you need
to have some variable to check if the user is actually logged in.

Good to know. I'll look into that more. SessionVar is a relatively new
thing isn't it? I've been sidetracked on other things for awhile so a
lot of my vibe stuff (and vibe knowledge) has bitrotted slightly. Last
thing I remember was that vibe sessions didn't really support typed
data, it was all stings IIRC.

Yeah, the whole vibe.web.* package got a lot of new stuff recently
(e.g. translation (i18n) and parameter validation support). I also still
have to update some projects to use those features, but the code
typically shrinks by around 30% in lines of code that way (+ also
horizontally), so far it has always been a pleasant experience.

BTW, sessions do support other types now, but the backend design still
needs some work, so that it also works for externally backed session
stores (it uses Variant internally right now).