[Gambas-user] Usage of session on web.gui

Benoit Minisini benoit.minisini at gambas-basic.org
Mon Apr 17 13:12:29 CEST 2023


Le 17/04/2023 à 09:48, Marco Ancillotti a écrit :
> Hi all ,
> 
> I have a web.gui app that have a login screen.
> 
> I have a main form called login that ask for user and password , then if 
> they are correct I do:
> 
>   WebForm.Current = MAIN
>   LOGIN.Reload()
> 
> (MAIN is the real app form that load if you insert right user and password)
> 
> Everything works but after some time it refresh to login window ( LOGIN 
> FORM ).
> That can be correct but I want to manage timeout's by users names so I 
> search and found session api.
> 
> On the login form after authentication I do:
> 
>    Session["username"] = "admin"
>    Session.Timeout = 36000
>    Session.Save()
> 
> And when a user click on a logoff button I do:
> 
>    Session.Abandon()
>    Session.Save()
>    WebForm.Current = LOGIN
>    MAIN.Reload()
> 
> All work's as expected but timeout is always the same , ignoring what I 
> put on session.timeout.
> 
> Anyone know what I do wrong ?
> 
> Thanks in advance,
> Marco.
> 

You must define the value of Session.Timeout earlier, before the session 
is actually created. For example in the "_init" method of your first 
form (the login form).

I will see if 'gb.web.gui' can take changes of this property into 
account, once the session has been created.

Regards,

-- 
Benoît Minisini.



More information about the User mailing list