如何验证会话. [英] how to validate Session....

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

问题描述

任何人都可以解释并给出C#编码以进行会话验证...




必须使用user_session id查找新用户或当前用户...

Can Anyone Explain & give C# coding for session validation...




have to find new user or current user using user_session id...

推荐答案

请告诉我们您需要哪种验证类型?
Please tell us you required to which type of validation?


Session["username"] = txtUsername.Text;

if(Session["username"] == null)
{
   //Redirect to login page.
}
else
{
   //Redirect to home page
}



问候,
-Eduard



Regards,
-Eduard


这是一些示例,希望它可以帮助您理解会话

here is some example hope it helps you to understand session

protected void btnImage_Click(object sender, ImageClickEventArgs e)
    {
        try
        {
            adp = new SqlDataAdapter("Select UserName from AdminLogin where UserName='" + txtusername.Text + "' and Password='" + txtpassword.Text + "'", conn);
            tbl = new DataTable();
            adp.Fill(tbl);
            if (tbl.Rows.Count == 0)
            {
                cls.MsgBox("Invalid UserName or Password...Login Failed", this.Page);
                txtpassword.Focus();
                return;
            }
            Session["User"] = tbl.Rows[0]["UserName"].ToString();
            Session["SessionId"] = "valid";
            Server.Transfer("Default.aspx");
        }
        catch (Exception ex)
        {
            cls.MsgBox(ex.Message, this.Page);
        }
    }


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

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