Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
|
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." NOT for ASP.NET 1.0, 1.1, or 2.0
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2004, 05:07 AM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to display username from cookies and log out?

hi..
straight forward.how it is? can it be done? and another question from this coding


<%
if Request("username") = "" or (CustomersRS.eof and CustomersRS.bof) then
response.redirect "CheckOutFail.asp"
else
if Request.Form("RememberMe") = "check" then
Response.Cookies("username").Expires=Date + 365
Response.Cookies("password").Expires=Date + 365
Response.Cookies("rememberme").Expires=Date + 365
response.cookies("username")=Request("username")
response.cookies("pass")=Request("password")
response.cookies("rememberme")=Request("RememberMe ")
else
Response.Cookies("username").Expires="1/1/80"
Response.Cookies("password").Expires="1/1/80"
Response.Cookies("rememberme").Expires="1/1/80"
end if
strFn=cstr(CustomersRS("firstname"))
Response.Cookies("firstname").Expires=Date + 365
response.cookies("firstname")=ucase(left(strFn,1)) & right(strFn,len(strFn)-1)
response.cookies("Products")("CustomerID")=Custome rsRS("CustomerID")
response.redirect "index.asp"
end if
%>


how can i display in my welcome page the "username" that just log in

i wrote it this way but its not working
<%response.write(request.cookies ("username"))%>

 thank you...

-aspnewbie (learn through try and error)


 
Old February 20th, 2004, 05:27 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi there,

Not sure what you're trying to accomplish. Your question is not as straight forward as the problem ;)

Anyway, the Response.Write statement you showed should work. Are you sure you correctly saved the cookie in the first place?

Is RememberMe a check box? Is its value attribute "check"> Otherwise, the code that sets the name won't run.
Did you check your cookies file on disk to see if the cookies are actually written?

And what about the "log out" feature? What are you trying to accomplish?

Cheers,

Imar



---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
 
Old February 21st, 2004, 02:45 AM
Registered User
 
Join Date: Feb 2004
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

i know about cookies.expires =date -1 but i dont really no how to apply it meaning after user log in,their username will be display and when they want to log out they will clik at "log out" so where do i need to place that expired code and how should i write it with proper sintax?

 
Old February 21st, 2004, 04:13 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

You could have the Logout link to Logout.asp.
On that page, set the Expires property of the cookie to a date in the past (-1 may not be enough, use a date further in the past) and then redirect to your homepage, for example.

<%
  Response.Cookies("username").Expires = Date() - 365
  Response.Redirect("/Default.asp")
%>

Cheers,

Imar


---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't get Log to write the Log.txt file jnbutler BOOK: Professional XNA Game Programming: For Xbox 360 and Windows ISBN: 978-0-470-12677-6 3 July 31st, 2007 04:04 AM
AppException Class -Log Error to Event Log bekim BOOK: ASP.NET Website Programming Problem-Design-Solution 7 December 7th, 2004 01:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.