在会话中存储用户 ID? [英] Store UserID in session?

查看:51
本文介绍了在会话中存储用户 ID?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要显示用户特定数据,我将当前登录用户的用户 ID 存储在哪里?会议?

To present user specific data, where do I store the userID of the user currently logged in? the Session?

推荐答案

是的,会话将是提供该信息的合适场所.假设您正在使用 ASP.NET 框架中的身份验证功能,您将从 HttpContext.Current.User.Identity.Name 加载用户 ID 或从该值中查找它.

Yes, the session would be an appropriate place for that information. Assuming you are using the authentication features baked into the ASP.NET framework, you will either be loading the user ID from HttpContext.Current.User.Identity.Name or looking it up from that value.

这篇关于在会话中存储用户 ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆