On Thursday, 10 December 2015 at 12:30:51 UTC, Suliman wrote:
On Thursday, 10 December 2015 at 12:21:40 UTC, Adrian Matoga
wrote:
On Thursday, 10 December 2015 at 11:36:20 UTC, Suliman wrote:
Vibed have method get for user session
http://vibed.org/api/vibe.http.session/SessionStore
I set user name for session like this:
req.session.set("username", "admin");
But I can't understand how to get user name from it:
abstract std.variant.VariantN!(20) get(
string id,
string name,
lazy std.variant.VariantN!(20) defaultVal
);
What does every string here mean? Could anybody to show
example of usage?
I think what you need is Session.get, not SessionStore.get:
http://vibed.org/api/vibe.http.session/Session.get
Give me example please
I found example in vibenews:
writeln("USER Session: ", req.session.get!string("username"));
but I can't understand why I should call it like this, but not
like
writeln("USER Session: ", req.session.get("username"));
And it's look like it do not return username, or user name are
set incorrectly:
if(dbuser == "admin") // admin name
hardcoded
{
_auth.isAuthorizated = true;
req.session.set("username", "admin");
}
else
{
req.session.set(request["username"].to!string, dbuser); //set
current username in parameter of session name
writeln("user name is: ", dbuser);
}