Forums
This topic is locked
Display username if cookie
Posted 03 Sep 2002 13:51:11
1
has voted
03 Sep 2002 13:51:11 John Gallagher posted:
Hi,I need to display a "Welcome Back )Username)" like on this site if a cookie has been recorded or "Why Not Register" text if it does not.
Any help, the cookie name is "ckLoggedin"
Thanks.
Later,
Webcrafty
Replies
Replied 03 Sep 2002 14:38:48
03 Sep 2002 14:38:48 Vince Baker replied:
You need to create a recordset that filters your user table by the Cookie. You can use the standard dreamweaver recordset function for this. I will assume your recordset is called rsUser and the username field is called Username.
<%
Dim strCookie, strUsername, strResponse
strCookie = Request.cookies("ckLoggedin"
strUsername = (rsUser.fields.item("Username".value)
%>
<%
If strCookie = "" then
strResponse = "Why not register"
else strResponse = "Welcome Back " & strUsername
End If
%>
Add the next line where you want the text to display
<% Response.write(strResponse) %>
Et Voila!
Regards
Vince
Response.write("The best line of code you can ever use"
VBScript | ASP | HTML | SQL | Oracle | Hosting
Replied 03 Sep 2002 15:59:39
03 Sep 2002 15:59:39 John Gallagher replied:
Right,
so the top code <pre id=code><font face=courier size=2 id=code><%
Dim strCookie, strUsername, strResponse
strCookie = Request.cookies("ckLoggedin"
strUsername = (rsUser.fields.item("Username".value)
%>
<%
If strCookie = "" then
strResponse = "Why not register"
else strResponse = "Welcome Back " & strUsername
End If
%>
</font id=code></pre id=code>
goes in the head, is that right.
this is my record set -
<img src="www.con-telegraph.ie/dream.gif" border=0>
Does it look OK?.
The other code goes in the page where I want the username to go.
Later,
Webcrafty
so the top code <pre id=code><font face=courier size=2 id=code><%
Dim strCookie, strUsername, strResponse
strCookie = Request.cookies("ckLoggedin"
strUsername = (rsUser.fields.item("Username".value)
%>
<%
If strCookie = "" then
strResponse = "Why not register"
else strResponse = "Welcome Back " & strUsername
End If
%>
</font id=code></pre id=code>
goes in the head, is that right.
this is my record set -
<img src="www.con-telegraph.ie/dream.gif" border=0>
Does it look OK?.
The other code goes in the page where I want the username to go.
Later,
Webcrafty
Replied 03 Sep 2002 16:17:35
03 Sep 2002 16:17:35 Vince Baker replied:
The initial code can go above the head as long as it is after the recordset (as we are calling information from the recordset) and yes, the response.write goes where you want to display the text.
Regards
Vince
Response.write("The best line of code you can ever use"
VBScript | ASP | HTML | SQL | Oracle | Hosting
Regards
Vince
Response.write("The best line of code you can ever use"
VBScript | ASP | HTML | SQL | Oracle | Hosting