开发者

should I sign the user with his Id or hi login?

开发者 https://www.devze.com 2023-04-03 21:35 出处:网络
the ids are autoincrement 1,2,3 ... etc. and the login\'s are string when I do FormsAuth.SignIn( //here should I use the login or the ids

the ids are autoincrement 1,2,3 ... etc. and the login's are string

when I do FormsAuth.SignIn( //here should I use the login or the ids

the logins aren't seen by anybody, but the ids aren't hard to guess 开发者_StackOverflow中文版(for some random person)


It depends on how you do your authentication. The standard generated forms-authentication expects a Username for the user to log in.

So when the user tries to login you should check his username and password against the database. If everything is correct then you can do.

FormsAuthentication.SetAuthCookie("UserName",true/false);

If you wrote your custom membership validation then you can set the AuthCookie to something else like the Id or Email. It just has to be unique.

What you are saying about the Id's aren't hard to quess shouldn't mather. Unauthorized persons shouldn't be able to do the FormsAuthentication.SetAuthCookie. You always have to check if the pass and username is correct so.

Hope it's clear enough for you?

0

精彩评论

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