| | |
Cookies
Thread Solved |
•
•
Join Date: Nov 2008
Posts: 58
Reputation:
Solved Threads: 0
I am trying to set a cookie but when i check my browser cookies nothing is set. What am doing wrong
Python Syntax (Toggle Plain Text)
#!/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\">"
![]() |
Similar Threads
- Netscape 7.1, Hotmail login problem - cookies 'disabled" (Windows NT / 2000 / XP)
- Where do Cookies come from? (Web Browsers)
- how can i used session and cookies ??? (PHP)
- Help me trouble with saving cookies win xp (Windows NT / 2000 / XP)
- Troubles with cookies win. xp (Windows NT / 2000 / XP)
- Cookies makers? (HTML and CSS)
Other Threads in the Python Forum
- Previous Thread: Dictionary Looping Name Error
- Next Thread: Error: "TypeError: argument of type 'int' is not iterable"
| Thread Tools | Search this Thread |
advanced aliased bash beginner bits calling casino changecolor clear command convert corners count csv cturtle cursor def definedlines dictionary digital dynamic dynamically event events examples external file float format frange function google gui hints homework i/o iframe import info input jaunty java line linux list lists loop matching mouse multiple number numbers obexftp output parsing path port prime programming projects py py2exe pygame pygtk python random rational raw_input recursion return scrolledtext signal singleton skinning stderr string strings subprocess table tails terminal text thread threading time tkinter tlapse tuple tutorial ubuntu unicode urllib urllib2 valueerror variable voip web-scrape whileloop word wxpython





