PDA

View Full Version : سوال: کدام دو روش امنيتي بهتر است ؟



mkhsoft
جمعه 18 بهمن 1387, 01:46 صبح
سلام
من براي سيستم امنيتي يک سايت دو روس رو در نظر گرفتم مي خواستم راهماييم کنيد ببينم کدوم بهتره که اجرا کنم يکيش همون FormsAuthentication هست و ديگري استفاده اط سشن.

کد امنيتي ساخت کوکي هم اينه:


[if (isvalid)
{
// Query the user store to get this user's User Data
string userDataString = string.Concat(row[0]["FName"], "|", row[0]["LName"], "|", row[0]["Role"]);

// Create the cookie that contains the forms authentication ticket
HttpCookie authCookie = FormsAuthentication.GetAuthCookie(txtUserName.Text , false);

// Get the FormsAuthenticationTicket out of the encrypted cookie
FormsAuthenticationTicket ticket = FormsAuthentication.Decrypt(authCookie.Value);


// Create a new FormsAuthenticationTicket that includes our custom User Data
FormsAuthenticationTicket newTicket = new FormsAuthenticationTicket(ticket.Version, ticket.Name, ticket.IssueDate,DateTime.Now.AddDays(1), ticket.IsPersistent,userDataString);

// Update the authCookie's Value to use the encrypted version of newTicket
authCookie.Value = FormsAuthentication.Encrypt(newTicket);

// Manually add the authCookie to the Cookies collection
Response.Cookies.Add(authCookie);
}

دومين روشم هم استفاده از سشن هست که اطلاعات را بعد از ورود در يه سشن ذخيره کنم
اما چون من مي خوام اطلاعات مهمي مثل بخش هايي که هر کاربر مي تونه دسترسي داشته باشه را نگهدار ي کنم ، حالا مي خوام ببينم کدوم بهتره يا اينکه آيا راه بهتري هم هست؟

ممنون