-
Notifications
You must be signed in to change notification settings - Fork 0
/
cookies.py
41 lines (29 loc) · 1.1 KB
/
cookies.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
from flask import make_response, Blueprint
cookies = Blueprint('cookies', __name__)
@cookies.route('/cookies/set_location/<string:coords>/')
def set_default_location(coords=None):
lat = coords.split(',')[0]
lng = coords.split(',')[1]
res = make_response()
res.set_cookie('last_latitude', lat, max_age=60 * 60 * 24 * 7 * 365)
res.set_cookie('last_longitude', lng, max_age=60 * 60 * 24 * 7 * 365)
return res
# Creates a verified cookie for user
@cookies.route('/cookies/verified/create/')
def create_verification_cookie():
res = make_response()
res.set_cookie('verified', 'true', max_age=60 * 60 * 24 * 7 * 365)
return res
# Creates UID cookie for user
@cookies.route('/cookies/uid/create/<string:uid>')
def create_uid_cookie(uid=None):
res = make_response()
res.set_cookie('uid', uid, max_age=60 * 60 * 24 * 7 * 365)
return res
# Deletes cookie upon logout
@cookies.route('/cookies/delete/<string:uid>')
def delete_uid_cookie(uid=None):
res = make_response()
res.set_cookie('uid', uid, max_age=0)
res.set_cookie('verified', 'true', max_age=0)
return res