Thread: cookielib help

    #1
  1. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    Lawrence, Kansas [KU]
    Posts
    1,559
    Rep Power
    15

    cookielib help


    i was using the Cookie module before to handle all of my login stuff but i was getting warnings in my error log not to use it so i want to switch to use cookielib ...but i am very confused on how to use it. i am usually very good at figuring stuff out....but i don't really know that much about cookies and with using PHP before i came over to python...cookies and sessions, were pretty freaking easy. and http://www.python.org/doc/current/li...cookielib.html isn't really helping me at all.

    so what's the best way to be up to date and use python as my main server-side language... for my logins too.

    i hope all of this made sense, thanks guys
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    Lawrence, Kansas [KU]
    Posts
    1,559
    Rep Power
    15
    anybody? :P

    i guess what i meant to say in so many words was:

    what do you use (w/ python 2.4) to handle cookies/sessions for your webapps? that doesn't use a deprecated module such as Cookie...


    thanks again
  4. #3
  5. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Hey Jack,

    I don't really know how I missed this thread twice . Sorry for that!

    Anyway, I would definitely suggest using cookielib over Cookies, which if you ask me is a terrible module! It's annoyed me so much that I even wrote my own

    I haven't used the cookielib module yet but it does look to have become more complex, although it does offer more control & better features now .

    You mention "login" in your first post. Are we talking about CGI here or are you using it for something else? I guess: what do you want to do exactly?

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    Lawrence, Kansas [KU]
    Posts
    1,559
    Rep Power
    15
    thanks for replying netytan!

    i just have a basic login script that i wrote that sets a cookie so the other pages they travel to also know that they're logged in, like a session. and then kill the cookie on logout.

    i wrote a class before (based heavily on someone elses) that used Cookie, but i can't find an example on how to actually use cookielib...and i really don't know that much about cookies, as i said before i used to just let php handle them for me, but now i am pretty into python and i am getting warnings in my error log like i said above (that i shouldn't use Cookie anymore), and i don't want to make it too easy for anyone to break in if there is a problem with the Cookie module.

    and yeah this is just cgi, i am not using zope or whatever else is out there.

    i hope this clears it up

    thanks for your help
  8. #5
  9. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    Hey Jack, this is just to let you know I haven't forgotten about you. I am looking for information on using cookielib with CGI but I haven't turned anything up as of yet. Right now it looks more like the module is for use with remote sites rather than on a server.

    If I don't find anything soon I'll get in touch with the Python guys and see if they can gi'me a hit.

    Take care,

    Mark.
    programming language development: www.netytan.com Hula

  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    Lawrence, Kansas [KU]
    Posts
    1,559
    Rep Power
    15
    hey netytan, thanks

    i haven't had any luck finding anything online, but i am still trying.

    thanks for staying with me
  12. #7
  13. Hello World :)
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2003
    Location
    Hull, UK
    Posts
    2,537
    Rep Power
    69
    I think I've figured this out, and your going to laugh when I tell you. The cookielib module isn't for use in CGI scripts, rather this is what the Cookie module is for obviously .

    The module itself hasn't been depreciated (like I assumed) but the Cookie/SmartCookie() class has, so using it generates a warning like you see in your log. Luckily you can still use the BaseCookie() and SimpleCookie() classes without any annoyances .

    Code:
    >>> import Cookie
    >>>
    >>> Cookie.Cookie()
    /Library/Frameworks/Python.framework/Versions/2.4/lib/python2.4/Cookie.py:712: DeprecationWarning: Cookie/SmartCookie class is insecure; do not use it
      DeprecationWarning)
    <SmartCookie: >
    >>> Cookie.BaseCookie()
    <BaseCookie: >
    >>> Cookie.SimpleCookie()  
    <SimpleCookie: >
    >>>
    This can probably be sorted in about 10 minutes so the change over shouldn't be anything too major. It just seems that we were looking in the wrong direction .

    Hope this helps,

    Mark.
    programming language development: www.netytan.com Hula

  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Intermediate (1500 - 1999 posts)

    Join Date
    Feb 2004
    Location
    Lawrence, Kansas [KU]
    Posts
    1,559
    Rep Power
    15
    haha, wow

    thanks netytan, now i know in what direction i need to go and it should be smooth sailing from here. thanks again.

IMN logo majestic logo threadwatch logo seochat tools logo