Alrighty just figured out my problem, hopefully it will apply to your case,
Lisandro!

The "name" attribute of the "remember_me" checkbox input is actually "keep
me logged in" on my local site (not sure if this changed with web2py
versions, or I just made this change and forgot it). Thus,
request.vars.remember_me was None every time, even if the checkbox was
actually checked. I changed my javascript and python code to use
"keep_me_logged_in" instead of "remember_me", and now it's working,

I would suggest using "print request.vars" in your login code, so you can
see what vars are actually getting passed in from the form. If there is no
"remember_me" variable, then that's most likely your main problem.



On Fri, Mar 20, 2015 at 12:11 PM, Mark Li <[email protected]> wrote:

> I'm not quite sure, all the relevant parts of your code match mine. I did
> just test this on my local site, and it doesn't work. However, it does work
> for the live site, so I'm going to take a look and see what's going on.
>
>
>
> On Fri, Mar 20, 2015 at 6:22 AM, Lisandro <[email protected]>
> wrote:
>
>> 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 a topic in the
>> Google Groups "web2py-users" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/web2py/HdoErSDw-z8/unsubscribe.
>> To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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.

Reply via email to