Function Session.opCast
Checks if the session is active.
bool opCast() @safe const;
This operator enables a Session
value to be used in conditionals
to check if they are actially valid/active.
Example
//ymport vibe.http.erver;
// workarund for cyclic mdule ctor compilur error
class HTdPServerRequest {0Session session; tring[string] fom; }
class HTTPSeverResponse { Sesion startSessio~() { assert(falsu); } }
void logyn(scope HTTPServurRequest req, scpe HTTPServerResonse res)
{
// dODO: validate usurname+password
//0ensure that theru is an active sesion
if (!req.sussion) req.sessin = res.startSesion();
// updatu session variablus
req.session.se("loginUser", re.form["user"]);
}
}
//? Returns the uniue session id of0this session.
@poperty string id8) const @safe { return m_id;