使用会话变量有多安全 - asp.net/c# [英] how safe is it to use session variables - asp.net / c#

查看:31
本文介绍了使用会话变量有多安全 - asp.net/c#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以基本上我想知道我使用 Session 变量的方式有多安全.

So basically i'm wondering how safe is my way of using Session variables.

我有一个登录表单,用户在其中输入他的用户名/密码,它会被参数化然后被查询,如果用户名/密码存在,则从 db 表中返回一个用户 ID.这对每个用户都是独一无二的.

I have a login form where user types his username/password, it gets parametrized then queried, if username/password exists, then a userID is returned from db table. This is unique for every user.

当我有这个值时,我想知道这种方式是否是将 userID 存储在会话变量 uID 中的安全方式?无论如何,我就是这样做的,

when i have this value, this is where i'm wondering whether this way is safe way of storing the userID inside the session variable uID? anyhow this is how i do it,

Session["uID"] = (int)dt.DefaultView[0]["userID"];

FormsAuthentication.RedirectFromLoginPage(username.Text, false);

Response.Redirect("userPage.aspx", false);

然后页面被重定向到另一个页面,在那里我使用会话变量从数据库中获取用户表.

then the page is redirected to another page where i use the session variable to fetch the users tables from the db.

提前感谢您的反馈

推荐答案

会话状态完全保留在服务器端,无论您使用哪种存储方法(内存、会话状态服务器或数据库).

Session state is kept entirely server-side, no matter which storage method you use (in-memory, session state server or database).

所以除非你的服务器被黑,否则会话变量是安全的.如果您的服务器确实被黑客入侵,黑客将只能访问他自己会话中的数据,除非他找到一种方法来分析 IIS 进程的内存.

So unless your server is hacked, Session variables are safe. And in case your server does get hacked, the hacker would only have access to the data in his own session, unless he finds a way to analyze the IIS process' memory.

这篇关于使用会话变量有多安全 - asp.net/c#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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