Ich versuche hier gerade einen Cookie zu setzen.
Hier mal der Code
Code: Alles auswählen
class Main:
def __init__(self, DBObj):
self.DBObj = DBObj
self.LOGIN = Cookie.SmartCookie()
try:
self.LOGIN.load(os.environ["HTTP_COOKIE"])
self.LOGIN_OK = self.LOGIN["pybb"].value
except:
self.LOGIN_OK = "NULL"
def Login(self, username, password):
if self.DBObj.CheckUser(username, password):
if self.LOGIN_OK == "NULL":
try:
self.LOGIN["pybb"] = "TEST"
self.LOGIN["pybb"]["expires"] = 360
self.LOGIN["pybb"]["path"] = "/"
return 1
except:
return 0
Aufrufen tu ich das so:
Code: Alles auswählen
DBObj = MySQLLayer.MySQL() # DB Obj.
FORM = cgi.FieldStorage() # Form Daten
BOARD = PyBoard.Main(DBObj) # Board Obj
if BOARD.Login(FORM["username"].value, FORM["password"].value):
BOARD.PrintHTMLHead()
Aber wieso nicht in der Klasse?
MfG und Danke
Andreas