| | |
Cookies
Please support our Python advertiser: Programming Forums - DaniWeb Sister Site
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"
Views: 510 | Replies: 1
| Thread Tools | Search this Thread |
Tag cloud for Python
anti array avogadro beginner builtin clear client code color count csv curved def dictionary dynamic enter examples excel file float format frange ftp function gui heads hints homework import input java lapse line lines linux list lists loop microcontroller mouse multiple mysqldb mysqlquery newb number numbers output parsing path port prime program programming projects py2exe pygame pyopengl pyqt python random raw_input recursion recursive redirect script scrolledtext singleton software sqlite ssh stderr string strings subprocess sum syntax table terminal text thread threading time tkinter tlapse tooltip tuple tutorial twoup ubuntu unicode unix urllib urllib2 variable web-scrape wikipedia windows word wx.wizard wxpython





