librelist archives

« back to archive

'remember me' functionality & populating the session

'remember me' functionality & populating the session

From:
Wells Oliver
Date:
2014-10-10 @ 23:34
Hey all.

How can I wire up my app to run a function every time the user is logged in
via the cookie set with Flask's remember=True functionality?

I have my nice login() method that calls login_user(...., remember=True)
AND populates some session information, but when the user comes back and is
logged in via flask's black magic remember me stuff, the session stuff
isn't populated.

Thanks!

-- 
Wells Oliver
wellsoliver@gmail.com

Re: [flask] 'remember me' functionality & populating the session

From:
Charles
Date:
2014-10-11 @ 01:34
On Sat, Oct 11, 2014 at 6:34 AM, Wells Oliver <wellsoliver@gmail.com> wrote:
> Hey all.
>
> How can I wire up my app to run a function every time the user is logged in
> via the cookie set with Flask's remember=True functionality?
>
> I have my nice login() method that calls login_user(...., remember=True) AND
> populates some session information, but when the user comes back and is
> logged in via flask's black magic remember me stuff, the session stuff isn't
> populated.

You should save the remember me information in a cookie, not in the
session cookie (the session itself is stored in a cookie, but you need
to store the remember be information in other cookie). Also you'd need
to set the cookie lifetime to a longer time (1 month, etc.).