ASP saves data to cookies

Source: Internet
Author: User
Tags md5
The code is as follows Copy Code

Sub Saveusercookie ()
Dim S_syskey,password,usercookies,truepassword,userclass,userhidden

S_syskey = Request.QueryString ("Syskey")
UserName = Newasp.checkbadstr (Request.QueryString ("UserName"))
Password = Request.QueryString ("Password")
Usercookies = Request.QueryString ("Savecookie")
If username= "" or s_syskey= "" Then Exit Sub
Dim NEWMD5,OLDMD5
NewMd5 = Md5 (UserName & Api_conformkey)
Md5old = 1
OldMd5 = Md5 (UserName & Api_conformkey)
Md5old = 0
If not (S_SYSKEY=NEWMD5 or S_SYSKEY=OLDMD5) Then
Exit Sub
End If
If usercookies= "" or Not IsNumeric (usercookies) Then usercookies = 0

' User exits
If Password = "" Then
Response.Cookies (newasp.cookies_name). Path = "/"
Response.Cookies (Newasp.cookies_name) ("userid") = ""
Response.Cookies (Newasp.cookies_name) ("username") = ""
Response.Cookies (newasp.cookies_name) ("password") = ""
Response.Cookies (Newasp.cookies_name) ("nickname") = ""
Response.Cookies (Newasp.cookies_name) ("usergrade") = ""
Response.Cookies (Newasp.cookies_name) ("usergroup") = ""
Response.Cookies (Newasp.cookies_name) ("userclass") = ""
Response.Cookies (Newasp.cookies_name) ("usertoday") = ""
Response.Cookies (Newasp.cookies_name) ("usercookies") = ""
Response.Cookies (Newasp.cookies_name) ("lasttimedate") = ""
Response.Cookies (Newasp.cookies_name) ("lasttimeip") = ""
Response.Cookies (Newasp.cookies_name) ("lasttime") = ""
Response.Cookies (Newasp.cookies_name) = ""
Exit Sub
End If
Chkuserlogin username,password,usercookies
End Sub

Function Chkuserlogin (username,password,usercookies)
Chkuserlogin = False
Dim rs,sql,group_setting

If not IsObject (Conn) Then connectiondatabase
Set Rs = Server.CreateObject ("ADODB.") Recordset ")
SQL = "SELECT * from [nc_user] WHERE username= '" & Username & "'"
Rs.Open SQL, Conn, 1, 3
If not (RS.BOF and rs.eof) Then
If Password <> Rs ("password") Then
Chkuserlogin = False
Exit Function
End If
If Rs ("UserLock") <> 0 Then
Chkuserlogin = False
Exit Function
End If
Response.Cookies (Newasp.cookies_name) ("lasttimedate") = Rs ("Lasttime")
Response.Cookies (Newasp.cookies_name) ("lasttimeip") = Rs ("Userlastip")
Response.Cookies (Newasp.cookies_name) ("lasttime") = Rs ("Lasttime")
Group_setting=split (Newasp.usergroupsetting (Rs ("Usergrade")), "| | |")
If Rs ("Userpoint") < 0 Then
Rs ("userpoint") = CLng (group_setting (25))
Else
RS ("userpoint") = RS ("Userpoint") + CLng (group_setting (25))
End If
If Rs ("experience") < 0 Then
Rs ("experience") = CLng (group_setting (32))
Else
RS ("experience") = RS ("experience") + CLng (group_setting (32))
End If
If Rs ("charm") < 0 Then
Rs ("charm") = CLng (group_setting (33))
Else
RS ("charm") = rs ("charm") + CLng (group_setting (33))
End If
Rs ("lasttime") = Now ()
Rs ("userlastip") = Newasp.getuserip
RS ("userlogin") = RS ("Userlogin") + 1
Rs.update

Select Case Usercookies
Case 0
Response.Cookies (Newasp.cookies_name) ("usercookies") = Usercookies
Case 1
Response.Cookies (Newasp.cookies_name). Expires=date+1
Response.Cookies (Newasp.cookies_name) ("usercookies") = Usercookies
Case 2
Response.Cookies (Newasp.cookies_name). Expires=date+31
Response.Cookies (Newasp.cookies_name) ("usercookies") = Usercookies
Case 3
Response.Cookies (Newasp.cookies_name). expires=date+365
Response.Cookies (Newasp.cookies_name) ("usercookies") = Usercookies
End Select
Response.Cookies (newasp.cookies_name). Path = "/"
Response.Cookies (Newasp.cookies_name) ("userid") = Rs ("userid")
Response.Cookies (Newasp.cookies_name) ("username") = Rs ("username")
Response.Cookies (newasp.cookies_name) ("password") = Rs ("password")
Response.Cookies (Newasp.cookies_name) ("nickname") = Rs ("nickname")
Response.Cookies (Newasp.cookies_name) ("usergrade") = Rs ("Usergrade")
Response.Cookies (Newasp.cookies_name) ("usergroup") = Rs ("UserGroup")
Response.Cookies (Newasp.cookies_name) ("userclass") = Rs ("UserClass")
Response.Cookies (Newasp.cookies_name) ("usertoday") = Rs ("Usertoday")
Chkuserlogin = True
End If
Rs.close
Set Rs = Nothing
End Function

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.