@@ -390,14 +390,17 @@ def delete_cookie(self, cookie_name=None):
390390
391391 return self .create_cookie ("" , "" , cookie_name = cookie_name , kill = True )
392392
393- def create_cookie (self , value , typ , cookie_name = None , ttl = - 1 , kill = False ):
393+ def create_cookie (self , value , typ , cookie_name = None , ttl = - 1 , kill = False ,
394+ same_site = "" , http_only = True ):
394395 """
395396
396397 :param value: Part of the cookie payload
397398 :param typ: Type of cookie
398399 :param cookie_name:
399400 :param ttl: Number of minutes before this cookie goes stale
400401 :param kill: Whether the the cookie should expire on arrival
402+ :param same_site:
403+ :param http_only:
401404 :return: A tuple to be added to headers
402405 """
403406 if kill :
@@ -435,6 +438,8 @@ def create_cookie(self, value, typ, cookie_name=None, ttl=-1, kill=False):
435438 enc_key = self .enc_key ,
436439 max_age = ttl ,
437440 sign_alg = self .sign_alg ,
441+ same_site = same_site ,
442+ http_only = http_only ,
438443 ** c_args
439444 )
440445
@@ -476,6 +481,8 @@ def append_cookie(
476481 path = None ,
477482 timestamp = "" ,
478483 max_age = 0 ,
484+ same_site = "None" ,
485+ http_only = True
479486 ):
480487 """
481488 Adds a cookie to a SimpleCookie instance
@@ -490,7 +497,8 @@ def append_cookie(
490497 :param max_age:
491498 :return:
492499 """
493- timestamp = str (int (time .time ()))
500+ if not timestamp :
501+ timestamp = str (int (time .time ()))
494502
495503 # create cookie payload
496504 try :
@@ -508,6 +516,8 @@ def append_cookie(
508516 enc_key = self .enc_key ,
509517 max_age = max_age ,
510518 sign_alg = self .sign_alg ,
519+ same_site = same_site ,
520+ http_only = http_only
511521 )
512522
513523 for name , args in content .items ():
0 commit comments