[mod_python] Tips and Tricks initiative ... some followup contribution

vio vmilitaru at sympatico.ca
Wed Jul 3 16:10:32 EST 2002


Generic Cookies

Description:
  How do we bake cookies in mod_python?

Solution:
  def handler(REQUEST):
    header_key = 'Set-Cookie'
    # set cookie values
    for header_value in (
'MyCookie1Var=homepop-shown=1; expires=Wed, 03-Jul-2002 05:18:07 GMT; path=/; domain=zzzz;', 
'MyCookie2Var=homepop-shown=0; expires=Wed, 03-Jul-2002 05:18:07 GMT; path=/; domain=zzzz;',
'MyCookieN=homepop-shown=0; expires=Wed, 03-Jul-2002 05:18:07 GMT; path=/; domain=zzzz;'
    ):
      REQUEST.headers_out.add(header_key,header_value)

    # set additional header arguments here

    # send header to client
    REQUEST.send_http_header()
    return apache.OK



More information about the Mod_python mailing list