ASP.Net中的会话密钥用法 [英] Session Key usage in ASP.Net

查看:121
本文介绍了ASP.Net中的会话密钥用法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

我有一个小型数据库项目,其中有各种用户登录,需要显示其相关数据取决于他们的用户数据.即该普通邮件应用程序我需要找出当前正在登录的用户并使用他的ID直到他注销此会话密钥变量为止更好,我认为但我不知道如何使用它.

请朋友发布如何使用会话变量以及我应该在哪里初始化该变量,以便在整个程序中都可以看到它,请提供完整的过程.


在此先感谢
Ganesh Kumar Poosarla

Hi Friends,

I am having small database project in which It has various users login and need to show their related data depends on their users data. i.e that normal mail application for that i need to trace out the which user is currently login and use his id through out until he logs out for this session key variable is better i thought but i dont know how to use it.

Please friends post how to use a session variable and where should i need to initialize the variable so that it is visible through out the program and please provide a complete procedure.


Thanks in Advance
Ganesh Kumar Poosarla

推荐答案

您无需初始化会话密钥.

当时用户在应用程序中登录时,可以设置一些会话变量

you no need to initialize the Session Key.

when user log-in in application at that time you can set some session variable
i.e
Session["Variable Name"]= value



您可以创建多个会话,例如Session ["UserName"],Session ["UserID"]等.

设置会话变量后,便可以在整个应用程序中使用它.

并且当用户关闭浏览器或从应用程序注销时,您可以清除会话.

您可以在asp.net中以不同的方式管理会话
会话变量



You can create a multiple session like, i.e Session["UserName"],Session["UserID"] etc..

Once you set the session variable then you can user it in whole application.

and When User will close the browser or logout from the application then you can clear the session.

you can manage Session in different ways in asp.net
Session Variable


是nigam ,

我们可以做到的.

例如,如果要在Session变量中获取TextBox值..

会话["UserName"] = txtUserName.text

以及是否要从数据库中获取用户的详细信息

您可以编写此查询..

从userMaster选择*,其中username = Session ["UserName"].ToString();

享受...!
Yes nigam,

We can do that..

For example if you want to get TextBox value in Session variable..

Session["UserName"] = txtUserName.text

and if you want to get details of user from database

you can write this query..

Select * from userMaster where username=Session["UserName"].ToString();

enjoy...!


嗨Nigam Patel

感谢您的回答
我们可以直接将文本框值分配给会话变量,还是可以使用会话变量从数据库中检索数据.

在此先感谢
Ganesh Kumar Poosarla.
Hi Nigam Patel

Thanks for your answer
Can we directly assign the text box value to a session variable and can we retrieve the data from database using the Session Variable.

Thanks in Advance
Ganesh Kumar Poosarla.


这篇关于ASP.Net中的会话密钥用法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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