Reputation: 30867
In a web application if a user check the Remember Me
box I'm gonna create a cookie and save it in database and assign it to user (long-life cookie). On any page request (page_load) I check this cookie (if session is null) and ask DAL for user object.
If I use GUID it would be unique but the question is if a user can guess the pattern maybe he could cheat by sending a hand-made cookie.
What is the best practice (C# sample) for creating such a text to be random enough ?
Upvotes: 1
Views: 174
Reputation: 46008
You can use FormsAuthentication.SetAuthCookie method (even if you don't use Forms authentication). There's no point in reinventing the wheel ;-)
Upvotes: 2