Bob Schneider
asked on
Creating Cookies in Classic ASP Site
I want to create cookies for a Remember Me functionality on http://www.gtraxc.com/login.asp
Here is how I create the cookie:
Here is where I retrieve it:
And here is how I attempt to place it in the appropriate form item values:
It does not appear to be working. Any help would be much appreciated.
Here is how I create the cookie:
If Request.Form.Item("remember-me") = "on" Then
Response.Cookies("user_name") = sUserName
Response.Cookies("password") = sPassword
End If
Here is where I retrieve it:
sUserName = Request.Cookies("user_name")
sPassword = Request.Cookies("password")
And here is how I attempt to place it in the appropriate form item values:
<fieldset class="form-group position-relative has-icon-left">
<input type="text" class="form-control form-control-lg input-lg"
name="user_name" id="user_name" placeholder="Your User Name" required=""
value="<%=sUserName%>">
<div class="form-control-position">
<i class="icon-head"></i>
</div>
</fieldset>
<fieldset class="form-group position-relative has-icon-left">
<input type="password" class="form-control form-control-lg input-lg"
name="password" id="user-password" placeholder="Enter Password" required=""
value="<%=sPassword%>" aria-invalid="false">
<div class="form-control-position">
<i class="icon-key3"></i>
</div>
</fieldset>
It does not appear to be working. Any help would be much appreciated.
ASKER
Thank you. What is a reasonable expiration time limit for cookies? Is there an industry standard?
I am not aware of a standard. I usually set that to a month.
No there is no standard as it is highly dependent on use case.
Setting an expiration time is optional - if you don't set it the cookie dies with the session (when you close the browser) - for some applications that is desirable.
A remember me does not fall into that category.
You need to decide how long you want to remember a user for (day, week, month) - I usually set it for a month and refresh it on logon.
Setting an expiration time is optional - if you don't set it the cookie dies with the session (when you close the browser) - for some applications that is desirable.
A remember me does not fall into that category.
You need to decide how long you want to remember a user for (day, week, month) - I usually set it for a month and refresh it on logon.
ASKER
I can't seem to get the user name and password box to populate. Here is how I am creating the cookies now:
Also, can I incorporate a variable into the expiration? Something like Date + 30
Response.Cookies("user_name") = sUserName
Response.Cookies("password") = sPassword
Response.Cookies("user_name").Expires=#March 1, 2020#
Response.Cookies("password").Expires=#March 1, 2020#
Also, can I incorporate a variable into the expiration? Something like Date + 30
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Try to trace the cookie creation and posting back using the F12 developer tool or Telerik Fiddler.