How to return user name from vibed session?

Suliman via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Dec 10 05:43:58 PST 2015


On Thursday, 10 December 2015 at 13:34:02 UTC, Mike Parker wrote:
> On Thursday, 10 December 2015 at 13:23:29 UTC, Suliman wrote:
>
>>
>> But question about why I need to get session info like:
>>
>> writeln("USER Session: ", req.session.get!string("username"));
>>
>> is still actual.
>
> When you have a template that looks like this:
>
> V get(V, K)(K key) {...}
>
> The compiler is able to deduce the type of K because of the 
> argument 'key'. However, there's no way for it to know what V 
> should be. You have to tell it explicitly when you instantiate 
> it:
>
> auto str = get!string("key1");
> auto i = get!int("key2");

So why for set both variant are work?

req.session.set("username", "admin");
req.session.set!string("username", "admin");


More information about the Digitalmars-d-learn mailing list