I am trying to set a cookie but when i check my browser cookies nothing is set. What am doing wrong
#!/usr/bin/python
# e begoli, python connector for mysql
# import MySQL module
import MySQLdb
import cgi
import Cookie
import time
cookie = Cookie.SimpleCookie()
cookie["ID"] = ""
print "Content-type: text/html\n"
# connection
db = MySQLdb.connect(host = "dsfdsfdsfsdf", user = "sdfsdfsdfsdf", passwd = "sdfsdfsdfdsfds", db = "dsfdsfdsfdsf")
form = cgi.FieldStorage()
if form.has_key("username")and form["username"].value !="" and form.has_key("password") and form["password"].value !="":
username = form["username"].value
password = form["password"].value
# create a database cursor
cursor = db.cursor(MySQLdb.cursors.DictCursor)
# execute SQL select statement
cursor.execute("SELECT * FROM User WHERE UserName = username AND Password = PASSWORD('"+password+"')")
# get the number of rows in the resultset
numrows = int(cursor.rowcount)
if numrows ==0:
print "<meta http-equiv=\"refresh\" content=\"0;url=http://adamplowman.com/uni_project/login.html\">"
else:
Results = cursor.fetchall()
for subelement in Results[0].keys():
if subelement == "Id":
ID = int(Results[0][subelement])
# get the number of rows in the resultset
numrows = int(cursor.rowcount)
cookie["ID"] = ID
print "<meta http-equiv=\"refresh\" content=\"0;url=http://adamplowman.com/uni_project/main.html\">"