Cookies 饼干让我发疯!ASP-VB脚本

Cookies 饼干让我发疯!ASP-VB脚本,cookies,vbscript,asp-classic,Cookies,Vbscript,Asp Classic,我正在尝试使用这些cookie,因此一旦用户/密码正确,它将启动cookie,以便用户在重新登录时始终显示用户名(记住我功能) 当我在同一页上检查“usernameCookie”时,这段代码给出了“usernameCookie”值,但它没有传递给下一页。好像它已经不存在了。当然,我使用了buffer=true,但这让我抓狂,为什么它不起作用 <%@ language="VBscript"%> <% response.buffer = True %> <!-- #in

我正在尝试使用这些cookie,因此一旦用户/密码正确,它将启动cookie,以便用户在重新登录时始终显示用户名(记住我功能)

当我在同一页上检查“usernameCookie”时,这段代码给出了“usernameCookie”值,但它没有传递给下一页。好像它已经不存在了。当然,我使用了buffer=true,但这让我抓狂,为什么它不起作用

<%@ language="VBscript"%>
<% response.buffer = True %>
<!-- #include file = "ddsn.asp" -->
<!-- #include file = "sfuncs.asp" -->

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<script src="js/jquery.validate.js" type="text/javascript"></script>

<!--Initiate form validation - in this example on the login form-->
<script type="text/javascript">
$(document).ready(function() {
    $("#loginform").validate();
});
</script>
<link href="css/styles.css" rel="stylesheet" type="text/css" />
</head>

<body>

<%
msg = ""

If request.form ("password") <> "" Then
    Set rs = Server.CreateObject("ADODB.RecordSet")

    SQL = "Select id,firstName,lastName,username,password,permissions,status FROM dispatchersTBL WHERE username='" & request.form ("username") & "' and password='" & request.form ("password") & "'"

    If inStr(1,SQL,";") or inStr(1,SQL,"''") OR inStr(1,LCase(SQL)," or ") Then msg = "<strong>Wrong Username or Password</strong>" End If

    rs.Open SQL,SQLDSN,3,1

    If NOT rs.EOF Then
        Session("login") = "True"
        Session("loggedUserID") = rs("id")
        Session("fullName") = rs("firstName") & " " & rs("lastName")
        Session("permissions") = rs("permissions")
        status = rs("status")
        Session.Timeout = 1440

        If status = "Inactive" Then
            msg = "<p><strong>Inactive User. Please contact the administrator.</strong></p>"
        Else
            response.cookies("usernameCookie") = rs("username")
            response.cookies("passwordCookie") = rs("password")
            response.cookies("usernameCookie").expires = Date() + 30
            response.cookies("passwordCookie").expires = Date() + 30

            response.redirect adminSiteURL & "co-worker-sms.asp"
        End If
    Else
        msg = "<p><strong>Wrong Username or Password</strong></p>"
    End if
    rs.Close
    Set rs = Nothing
End if
%>

<div id="admin_wrapper">
    <form action="default.asp" id="login" method="post">
        <%=msg%>

        <!-- TEXTBOXES -->
        <label>Username</label><br />
        <input name="username" type="text" value="<%=request.cookies("usernameCookie")%>" class="text large required" id="username" /><br />

        <div class="clearfix">&nbsp;</div>

        <label>Password</label><br />
        <input name="password" type="password" value="<%=request.cookies("passwordCookie")%>" class="text large required" id="password" /><br />

        <div class="clearfix">&nbsp;</div>

        <p><input name="btnLogin" type="submit" class="submit" id="btnLogin" value="LOGIN" /></p>
    </form>
</div>

</body>
</html>

$(文档).ready(函数(){
$(“#loginform”).validate();
});
用户名

密码


我遗漏了什么?

我没有看到您的登录页面,但您的代码似乎正常-您确定在尝试检索时执行了request.cookies吗

试着做一个这样简单的页面

<%
' put cookie 
Response.Cookies("usernameCookie") = "Superman"
Response.Cookies("usernameCookie").Expires = Date() + 10

Response.Cookies("passwordCookie") = "Batman"
response.Cookies("passwordCookie").Expires = Date() + 10
%>

<% ' Print my cookie %>
<input type="text" value="<% = request.cookies("usernameCookie") %>" name="username">
<br />
<input type="text" value="<% = request.cookies("passwordCookie") %>" name="password">



重新加载页面后,您的输入字段中应该有“超人”和“蝙蝠侠”

尝试发布您的所有代码,我会看看问题出在哪里。好的,我更新了我原来的帖子。不确定这是否重要,但我正在使用一个子域:admin.mydomain.com