title: GAE Python - Saving database query into cookie
body: <p>I am trying to save a database query into a cookie since I require the result on every page. When hard-coding an expiry-date into the code everything works fine, but when I replace the hard-coded date by a dynamic "next day" expiry, it is giving me the following error:</p>
  
  <pre><code>self.response.headers.add_header(str('Set-Cookie'), str('shops=%s; path=/; expires=%s') % shoplist expire_string)
                                                                                                                 ^
  SyntaxError: invalid syntax
  </code></pre>
  
  <p>I also tried to use the response.set_cookie method but this didn't work at all, which is why I decided to go with the code below:</p>
  
  <pre><code>class CookieHandler(webapp2.RequestHandler):
      def get(self):
          shoplist = Shop.all().filter('active = ', True).order('abbrev')
          expire_date = datetime.datetime.now() + datetime.timedelta(days=1)
          expire_string = expire_date.strftime('%a, %d %b %Y %H:%M:%S GMT')
          self.response.headers.add_header(str('Set-Cookie'), str('shops=%s; path=/; expires=%s') % shoplist expire_string)
  </code></pre>
  
  <p><strong>UPDATE</strong>
  To give some more information about the content - it is a query of all shopnames in a database. The query is used for an autocomplete functionality on a searchbox that is visible on every page.</p>