会话登录控制 [英] login control with session

查看:82
本文介绍了会话登录控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我的应用程序从登录页面重定向,用户名和密码从数据库中调用.这里我还有另外3或4个页面,这些页面在没有登录权限的情况下没有打开,这些页面也只能正确加载用户名和密码.如果我尝试执行这些页面中的任何一个而没有登录,它将自动重定向到登录页面.所有页面仅打开正确的用户名和密码.我想使用会话来存储用户名和密码.

Hi, my application redirects from the login page, user name and passwords are called from the data base.Here i have another 3 or 4 page that are not opened with out a login permissions, these pages are also be loaded only right user name and password. if i am trying to execute any of these pages without login it automatically redirects to the login page. all the pages are opened only for right user name and password.i want to use session to store the user name and passwords. can any one help me how to write code for this.

推荐答案

为什么不研究这个项目ASP.NET 3.5中的登录控件 [
Why don''t you study this project Login Control in ASP.NET 3.5[^]. It looks like something you could use.

Best Regards,

—MRB


登录后,将登录值(用户ID,用户名)存储在Session中.
After login, store the login values(UserID, UserName) in Session.
Session["UserID"] = "user1";


在下一页中,检查page_load中的会话值.如果失败,则重定向到登录页面.


In next page Check the session value in page_load & if it fails then redirect to login page.

if(Session["UserID"] != null)
{
  Response.Redirect("login.aspx");
}


注销后,放弃Session&重定向到登录页面.


After logout Abandon the Session & redirect to login page.


这篇关于会话登录控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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