I'm having trouble to get this to work.
I've already implemented my own login through ajax, but I can't get to work
the "remember me" part.
This is my code:
def _login():
email = request.post_vars.email
password = request.post_vars.password
remember = request.post_vars.remember
user = auth.login_bare(email, password)
if not user:
return response.json({'success':False})
else:
if remember:
session.auth.expiration = 3600 * 24 * 30 # one month
session.auth.remember = True
response.cookies[response.session_id_name]["expires"] =
session.auth.expiration
return response.json({'success':True})
However, I login, close the browser, reopen it, and I'm asked to login
again. What am I missing?
El jueves, 6 de junio de 2013, 19:07:31 (UTC-3), Anthony escribió:
>
> Yes, sorry, there's one more thing you have to do -- you have to convert
> the session cookie to a non-session cookie:
>
> response.cookies[response.session_id_name]["expires"] = session.auth.
> expiration
>
> That will happen the next time Auth is initialized (which would happen on
> the next request), but it won't happen if you simply close the browser.
>
> Anthony
>
> On Thursday, June 6, 2013 5:33:37 PM UTC-4, Mark Li wrote:
>>
>> Here's the relevant part of the code I'm using. I make an ajax call to
>> the function below
>>
>> def ajax_login():
>> email = request.vars.email
>> password = request.vars.password
>> remember_me = request.vars.remember_me
>>
>> user = auth.login_bare(email, password)
>> if user:
>> if remember_me:
>> session.auth.expiration = auth.settings.long_expiration
>> session.auth.remember = True
>>
>>
>>
>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.