Cookie Trouble../images/Emo3.gif
אני מנסה ליצור עוגיה עם נתונים בעזרת הקוד הבא:
אני מנסה ליצור עוגיה עם נתונים בעזרת הקוד הבא:
Response.Write("Creating Cookie......."); HttpCookie cookie = new HttpCookie("details"); try { cookie.Values.Add("logged", rem.ToString()); cookie.Values.Add("username", username); cookie.Values.Add("password", Statics.EncryptPass(pass)); Response.Cookies.Add(cookie); Response.Write("Cookie Created<br>"); return true; } catch(Exception ex) { Response.Write("ERROR: "+ex.Message); return false; }
כשאני מריץ את הפונקציה אז הוא מודיע שהוא יצר את העוגיה אבל לאחר מכן כשאני מנסה לבדוק אם העוגיה קיימת בעזרת הקוד הבא:HttpCookie cookie = Request.Cookies["details"]; if(cookie == null) { Response.Write("False!<br>"); return false; } else { Response.Write("True<br>"); return true; }
אני מקבל הודעה שהיא לא קיימת... מה קורה כאן??