Problem w/Cookies Module?

junkster at junkster at
Thu May 11 16:48:58 CEST 2000

	I'm having some odd-ball problems with v2.25 (05/03/2000) of
the Cookie module.  I originally thought that it was the ODBC process
behind this web CGI that was causing the lockup, but through trial and
error testing, it appears to be related to the cookies module.

        The program I've attached, seems to "lock up".

	Here's the steps I can use to reproduce it:

		1) Browse to the CGI (i.e.
			- Writes the cookies initially
		2) Hit "Refresh" which will read the cookies from the
environmental value
			- Check to ensure it looks AOK

		3) Hit "Refresh" again, the web browser will sit there
until it times out.

	This is happening extremely reliably on the Win NT v4 (Service
Pack 6a) unit that I'm testing this code on.

	Has anyone heard of this (or other) problems?  This is the
first serious attempt to use the cookie module, so I'm not sure if this
is a implementation problem, or a code error.

			- Benjamin

import cgi
import cookie
import os
import sys
import string
import time

def	load_cookie ():
	user_info = cookie.SmartCookie()
		#	Load Cookie
		user_info.load (os.environ["HTTP_COOKIE"])
	except KeyError:
		# 	Cookie Does not exist

	return user_info

def	get_cookie_data (cookie_data, keyword):
	data = ""
		data = cookie_data[keyword].value
	return data

def	output_cookie ( cookie_data ):
	print cookie_data

cookie_data = load_cookie()

print "Context-Type: Text/Html"
if (len(sys.argv) > 1) and (string.upper(sys.argv[1]) == "LOGOUT"):
	cookie_data["user_name"]	= ""
	cookie_data["password"]  	= ""
	cookie_data["blah"]		= ""
	output_cookie (cookie_data)

elif len(cookie_data) == 0:
	cookie_data["user_name"] 	= "jjavier"
	cookie_data["password"]  	= "jjavier"
	cookie_data["real_name"]	= "Javier Jimenez Gomez"
	output_cookie (cookie_data)

print "<HTML> <HEAD> </HEAD> <BODY>"
print "Loaded from Cookie:"
print "<UL>"
print "<LI> User Name : ", get_cookie_data (cookie_data, "user_name")
print "<LI> password  : ", get_cookie_data (cookie_data, "password")
print "<LI> Real Name : ", get_cookie_data (cookie_data, "real_name")
print "</UL>"

print "</BODY>"
print "</HTML>"

Sent via
Before you buy.

More information about the Python-list mailing list