| |

VerySource

 Forgot password?
 Register
Search
View: 597|Reply: 3

Question about Session.

[Copy link]

2

Threads

5

Posts

6.00

Credits

Newbie

Rank: 1

Credits
6.00

 China

Post time: 2020-1-31 23:20:01
| Show all posts |Read mode
I wrote a verification code generation face, and then use the image control in the place where I log in, realistically, but when I log in the verification code is wrong, you can log in, what's going on, thank you!
The code judged by my session:
 if (Session ["checkCode"]. ToString ()! = validaor.Text.ToString ())
        {

            lbMessage.Visible = true;
            lbMessage.Text = "Wrong verification code!";

        }


Validate page code.
protected void Page_Load (object sender, EventArgs e)
    {
        if (! Page.IsPostBack)
        {
         string checkCode = CreateRandomCode (4);
         Session ["CheckCode"] = checkCode;
         CreateImage (checkCode);
            
        }

        


    }
Reply

Use magic Report

0

Threads

43

Posts

29.00

Credits

Newbie

Rank: 1

Credits
29.00

 China

Post time: 2020-3-12 19:15:01
| Show all posts
if (Session ["checkCode"]. ToString ()! = validaor.Text.ToString ())
        {

            lbMessage.Visible = true;
            lbMessage.Text = "Wrong verification code!";

        }
  else
      {Call login process}
Reply

Use magic Report

0

Threads

9

Posts

7.00

Credits

Newbie

Rank: 1

Credits
7.00

 China

Post time: 2020-3-13 13:15:01
| Show all posts
string strSql = "select * from yqj_manager where login_txt_name = '" + txtName.Text + "' and login_txt_pass = '" + txtPwd.Text + "'";
ClassData cd = new ClassData ();
DataSet ds = new DataSet ();
ds = cd.DS (strSql);
if (ds.Tables [0] .Rows.Count> 0)
{
if (Request.Cookies ["CheckCode"] == null)
{
lblMessage.Text = "Your browser settings have disabled cookies. You must set your browser to allow cookies option to use this system.";
lblMessage.Visible = true;
string IP = Request.ServerVariables ["LOCAL_ADDR"]. ToString ();
string strSql1 = "update yqj_manager set lastlogin_time = '" + DateTime.Now + "', last_login_ip = '" + IP + "' where login_txt_name = '" + txtName.Text + "' and login_txt_pass = '" + txtPwd.Text + "'" ;;
cd.DataWork (strSql1);
return;
}
if (String.Compare (Request.Cookies ["CheckCode"]. Value, txtValidate.Text, true)! = 0)
{
lblMessage.Text = "Wrong verification code. Please enter the correct verification code.";
lblMessage.Visible = true;
return;
}
Session ["user"] = txtName.Text;
Response.Redirect ("admin_base.aspx");
}
else
{
Response.Write ("<script language = javascript> alert ('The username or password is wrong, please reconfirm!'); History.back (-1) </ script>");
}
The above is written by my own landing page, you research it yourself
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-3-13 14:45:01
| Show all posts
if (Session ["checkCode"]. ToString ()! = validaor.Text.ToString ())

should be
if (Session ["CheckCode"] ToString ()! = validaor.Text.ToString ())

Wrong capitalization
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list