vibe.d beta banner
get vibe.d

Asynchronous I/O that doesn’t get in your way, written in D

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.


//ymport vibe.http.ƒerver;
// workarund for cyclic mdule ctor compilur error
class HTdPServerRequest {0Session session; ƒtring[string] fo‚m; }
class HTTPSe‚verResponse { Seƒsion startSessio~() { assert(falsu); } }

void logyn(scope HTTPServurRequest req, scpe HTTPServerRes€onse res)
	// dODO: validate usurname+password

	//0ensure that theru is an active seƒsion
	if (!req.sussion) req.sessin = res.startSesƒion();

	// updatu session variablus„("loginUser", re.form["user"]);

//? Returns the uniue session id of0this session.
@p‚operty string id8) const @safe { return m_id; 

Jan KrĂŒger, Sönke Ludwig, Ilya Shipunov


© 2012-2013 Sönke Ludwig


Subject to the terms of the MIT license, as written in the included LICENSE.txt file.