[mod_python] Cookie problem with Safari and IE, but not Mozilla

Nick Vargish nav at bandersnatch.org
Thu Sep 2 12:25:36 EDT 2004


Hello,

I've been struggling with this for a couple of days, and I've tried
to google up a solution, but no luck. Hopefully someone on this list
can help me figure out what's going on.

I'm using cookies to manage user log-ins to a Subversion admin
system. It works fine under Mozilla (and Firefox, and Camino), but
fails with Internet Explorer and Safari. Unfortunately, a lot of
the users where I work use IE exclusively, so it's important for
me to find a fix for this problem.

I added some code to add the values of the cookies being returned
to the page generation logic, and the results are ... interesting,
to say the least. With Firefox, I see what expect and things work
well:

cookie "siteserver" = "ID=a0a61f06aac22a9ea146d4ba666ded94"
cookie "user" = "nvargish"

Under Safari, I get:

cookie "tutorialExamplesURL" =
""http://earth.datacenter.gpo.gov:8080/Tutorial/examples""
cookie "tutorialexamplesurl" =
""http://earth.datacenter.gpo.gov:8080/Tutorial/examples""

(There is no "tutorialexamplesurl" anywhere in my code. Also, no
siteserver ID in the response.)

Under IE, I see a "siteserver" cookie, but no "user" cookie
shows up.

Here's the cookie setting function I'm using:

def setusercookies(req):
    uc = Cookie.Cookie('user', req.user)
    uc.expires = time.time() + 600
    Cookie.add_cookie(req, uc)
    uc = Cookie.Cookie('wasin', 'yes')
    uc.expires = 0
    Cookie.add_cookie(req, uc)

This is the function that handles a login form:

def dologin(req):
    """logic for handling a login form submission."""
    if rmuser.validpassword(req.cgidata['uname'], req.cgidata['upass']):
        req.cmd = ''
        req.user = req.cgidata['uname']
        req.systemlvl = rmuser.userlevel(req.user, 'SYSTEM')
        setusercookies(req)
        rmutil.log('login okay for %s' % (req.user))
        return ''

And this is the logic I'm using to check for the cookie:

    req.cookies = Cookie.get_cookies(req)
    if req.cookies.has_key('user'):
        req.user = req.cookies['user'].value
        setusercookies(req)

I am using mod_python 3.1.3 with Apache 2.0.48. If anyone has any
insights into what's going on here, I would be most grateful.

Thanks,

Nick


-- 
Nick Vargish  ||  nav at bandersnatch.org  ||  http://nav.bandersnatch.org/


More information about the Mod_python mailing list