ASP Response.Cookies() - Response Object Gets the response cookie collection
ShotDev Focus:
- Gets the response cookie collection
Example
asp_response_cookies1.asp
<% Option Explicit %> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <% '*** Cookies None Key ***' Response.Cookies("SiteName").Expires = Now + 7 Response.Cookies("Creator").Expires = Now + 7 Response.Cookies("SiteName") = "www.ShotDev.Com" Response.Cookies("Creator") = "Mr.Weerachai Nukitram" '*** Cookies Have Key ***' Response.Cookies("User")("Username") = "Weerachai" Response.Cookies("User")("Password") = "MyWin" Response.Cookies("User")("Level") = "Admin" Response.Cookies("User")("Status") = "Active" Response.Cookies("User").Expires = Now + 7 Response.write("Cookies Created<br><br>") Response.write("<a href=asp_response_cookies2.asp>Check Cookies</a>") %> </body> </html>
asp_response_cookies2.asp
<% Option Explicit %> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <% '*** Cookies None Key ***' Response.write "SiteName = "& Request.Cookies("SiteName") & "<br>" Response.write "Creator = "& Request.Cookies("Creator") & "<br>" Response.write("<hr>") '*** Cookies Have Key ***' Response.Cookies("User").Expires = Now + 7 Response.Cookies("User")("Username") = "Weerachai" Response.Cookies("User")("Password") = "MyWin" Response.Cookies("User")("Level") = "Admin" Response.Cookies("User")("Status") = "Active" Response.write "Username = "& Request.Cookies("User")("Username") & "<br>" Response.write "Password = "& Request.Cookies("User")("Password") & "<br>" Response.write "Level = "& Request.Cookies("User")("Level") & "<br>" Response.write "Status = "& Request.Cookies("User")("Status") & "<br>" Response.write("<hr>") Dim List IF Request.Cookies("User").HasKeys Then For Each List In Request.Cookies("User") Response.write List &" = " & Request.Cookies("User")(List) & "<br>" Next End IF Response.write("<br><br><a href=asp_response_cookies3.asp>Delete Cookies</a>") %> </body> </html>
asp_response_cookies3.asp
<% Option Explicit %> <html> <head> <title>ShotDev.Com Tutorial</title> </head> <body> <% '*** Cookies None Key ***' Response.Cookies("SiteName").Expires = Now Response.Cookies("Creator").Expires = Now '*** Cookies Have Key ***' Response.Cookies("User").Expires = Now Response.write("Cookies Deleted<br><br>") Response.write("<a href=asp_response_cookies2.asp>Check Cookies</a><br>") Response.write("<a href=asp_response_cookies1.asp>Create Cookies</a><br>") %> </body> </html>
Create a asp file and save to path root-path/myasp/
Run
http://localhost/myasp/asp_response_cookies1.asp
Screenshot
.
.
.