I need to implement the following:
- User input user id and pass
- We validate that on another server
- If they are correct, cookies with these details should be saved for one month
- Each time user uses my site, we should look for cookies
- If they are not found - go to step 1
How can I set cookies for 1 month?
Will the following work?
self.response.headers.add_header(
'Set-Cookie',
'credentials=%s; expires=Fri, 31-Dec-2020 23:59:59 GMT' \
% credentials.encode())
How to calculate one month from now in the required format?
You can use webapp.Response.set_cookie() method:
Formatting dates for cookies is something like this: