Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help with a cookie

Status
Not open for further replies.

exphtur

Technical User
Jul 23, 2003
23
IE
I need a little help with a cookie please, I want to be able to set a cookie which gets the last login time of a member so that when they visit again they get a message saying something like 'Welcome, you are logged in since 'xxxxx time' and you last logged in at 'xxxxx time'.


<%
dim conn, rs
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
conn.open "Provider=Microsoft.JEt.OLEDB.4.0;Data Source=Z:\videostore\videostore.mdb;Persist Security Info=False"

sql = "SELECT UserName, FName, Password FROM [tblMember]"

rs.Open sql, conn, 3, 3

Dim strFName, strPassword

strFName = Trim(Request.Form("txtName"))
strPassword = Trim(Request.Form("txtPassword"))

If LCase(strFName) = "guest" Then
session("logintime") = time
session("logindate") = date

Response.Redirect "videostoremain.asp"
Else
rs.Find = "UserName = '" & strFName & "'"

If rs.EOF then
Response.Redirect "Login.asp?Error=Username not found"
Else
If strPassword = rs("Password") Then
session("FName") = rs("FName")
session("logintime") = time
session("logindate") = date
Response.Redirect "videostoremain.asp"
Else
Response.Redirect "Login.asp?Error=Invalid Password"
End If
End If
End If
%>

Main page

Welcome
You are logged in since <%session("logintime") = time%>
Today's date is <%session("logindate") = date %>
 
The problem is that your not outputting anything in those ladst two lines, only assigning values to the items in te session collection. Also I don't see any cookie references in there so I am going to assume this is an addition you would like to make, but haven't started on yet.

If the bottom was supposed to be symbolic output rather than part of the code or real output, forgive me for not catching that.

As far as the cookies are concerned, you can find all the references and examples needed at the Cookies Reference at W3Schools.

Hope this helps,
-T

01000111 01101111 01110100 00100000 01000011 01101111 01100110 01100110 01100101 01100101 00111111
The never-completed website:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top