如何安全是它使用会话变量 - asp.net / C# [英] how safe is it to use session variables - asp.net / c#

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

问题描述

所以基本上我不知道如何安全是我使用Session变量的方法。

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

我有一个登录表单,用户输入自己的用户名/密码,它就会被参数化查询,然后,如果用户名/密码存在,那么用户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.

当我有这个价值,这就是我想知道这种方式是否是存储会话变量UID内的用户ID的安全的方式?无论如何,这是我要做的事,

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).

所以,除非你的服务器被黑客攻击,Session变量是安全的。而如果您的服务器不遭到黑客入侵,黑客只在他自己的会话访问数据,除非他找到一个方法来分析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天全站免登陆