1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Rep Power

    Rietrieving cookies help again

    This is an example script that sets a cookie, i made it up real fast so it might have a slight error in it somewhere.

    import Cookie
    import id

    id = id.generateid()

    IFcookie = Cookie.SimpleCookie()
    IFcookie['id'] = id
    IFcookie['usrname'] = 'conrad'

    print IFcookie
    print 'Content-type: text/html\n'
    print 'cookie set'

    This is where i run into problems this is the code i use to retrieve these cookies:


    import cgitb
    import Cookie
    import os


    value = os.environ['id']

    print "Content-type: text/html\n"
    print value

    It says its a Key Error and that 'mapping key cannot be found'

    it points the error at this statement:
    value = os.environ['id']

    the error message says that it cannot find id
    even though i check my cookie list in mozilla and see that its there. Any help would be appreciated.

    BTW this is the last peice I need to implement before i put an alpha vrsion of my forums up. Next I'll need to rewrite them into oop before beta and release.
  2. #2
  3. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Hull, UK
    Rep Power
    You want to look in os.environ['HTTP_COOKIE'], this will return a string which you'll need to parse if you wana use it! But why not just use load()?

    programming language development: www.netytan.com Hula

IMN logo majestic logo threadwatch logo seochat tools logo