title: python saving jwt token in SimpleCookie
body: <p>My goal is to create a cookie that stores the jwt`s id token and pass it back to the client side. This logic is running in an aws lambda :</p>
  <pre><code>def lambda_handler(event, context):
  .....
  .....
  cookie_name=&quot;my_cookie&quot;
  cookie = gen_cookie(domain, expiration, cookie_name,jwt):
  return {&quot;statusCode&quot;: 302,
          &quot;headers&quot;: {
              &quot;Location&quot;: &quot;different-url/logged-in&quot;,
              &quot;Set-Cookie&quot;: cookie}
          }
  
  def gen_cookie(domain, expiration, cookie_name,jwt):
      cookie = SimpleCookie()
      cookie[cookie_name] = &quot;test&quot;
      cookie[cookie_name]['httponly'] = &quot;yes&quot;
      cookie[cookie_name]['domain'] = domain
      cookie[cookie_name]['expires'] = expiration
      cookie[cookie_name]['path'] = &quot;/&quot;
      cookie[cookie_name]['id_token'] = jwt['id_token']
      print(cookie)
      return cookie
  </code></pre>
  <p>I'm getting an exception that the id_token isnt a valid attribute.</p>
  <pre><code>[ERROR] CookieError: Invalid attribute 'id_token'
  Traceback (most recent call last):
    File &quot;/var/task/lambda_function.py&quot;, line 41, in lambda_handler
      cookie[cookie_name]['id_token'] = response_content_dict['id_token']
    File &quot;/var/lang/lib/python3.7/http/cookies.py&quot;, line 311, in __setitem__
      raise CookieError(&quot;Invalid attribute %r&quot; % (K,))
  </code></pre>
  <p>I checked and the only valid values in the simpleCookie are :</p>
  <pre><code>  _reserved = {
          &quot;expires&quot;  : &quot;expires&quot;,
          &quot;path&quot;     : &quot;Path&quot;,
          &quot;comment&quot;  : &quot;Comment&quot;,
          &quot;domain&quot;   : &quot;Domain&quot;,
          &quot;max-age&quot;  : &quot;Max-Age&quot;,
          &quot;secure&quot;   : &quot;Secure&quot;,
          &quot;httponly&quot; : &quot;HttpOnly&quot;,
          &quot;version&quot;  : &quot;Version&quot;,
      }
  </code></pre>
  <p>So my question is, how can I create a cookie that contains the jwt and return it to the client side ?</p>