开发者

Randomness vs Uniqueness?

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).开发者_Go百科 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 ?


You can use FormsAuthentication.SetAuthCookie method (even if you don't use Forms authentication). There's no point in reinventing the wheel ;-)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜