ASP

 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me



Go Back   Tutorialized ForumsWeb Design & DevelopmentASP

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Tutorialized Forums Sponsor:
  #1  
Old January 24th, 2005, 03:13 PM
viewer viewer is offline
Contributing User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2005
Posts: 1 viewer New User: is a brand new recruit and a unknown entity at this point. 
Time spent in forums: < 1 sec
Reputation Power: 0
How to read and write cookies in ASP?

Hi I've been searching around and found a lot of sample code but none seem to be working for me. Can someone here help?

This is what I have for writing:
' Sometimes writting the cookie, so I kill it first.
Response.Cookies("MySite")("var1")=var1
response.cookies("MySite").Expires=Date() -1

' Really where I write the cookie.
Response.Cookies("MySite")("var1")=var1
Response.Cookies("MySite")("var2")=var2
response.cookies("MySite").Expires=#January 1,2025#


This is what I have for reading:
var1 = Request.Cookies("MySite")("var1")
var2 = Request.Cookies("MySite")("var2")


var1 and var2 are always empty. When I go to view the cookied that was written, through IE Tools > Internet Options ... my cookie is simply named '[sitename]' rather than 'cookie:user@site.com'. I think this may be the reason I can't read the cookie. Now when I open the cookie in notepad, it looks correct.

MySitevar1=FirstVar&var2=SecondVarlocalhost/MySite1024430100483115316269161793629688409*


Any help would be much appreciated.

Reply With Quote
  #2  
Old February 20th, 2017, 06:01 AM
Rashmi.Padia Rashmi.Padia is offline
Registered User
Tutorialized Newbie (0 - 499 posts)
 
Join Date: Jan 2017
Location: Ahmedabad
Posts: 24 Rashmi.Padia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 11 h 8 m 8 sec
Reputation Power: 0
How to read and write cookies in ASP?

Hi,

You try this code to Read and Write Cookies in ASP.

Code:
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("user")("firstname")="John"
Response.Cookies("user")("lastname")="Smith"
Response.Cookies("user")("country")="Norway"
Response.Cookies("user")("age")="25"
%>


Code:
<!DOCTYPE html>
<html>
<body>

<%
dim x,y
for each x in Request.Cookies
  response.write("<p>")
  if Request.Cookies(x).HasKeys then
    for each y in Request.Cookies(x)
      response.write(x & ":" & y & "=" & Request.Cookies(x)(y))
      response.write("<br>")
    next
  else
    Response.Write(x & "=" & Request.Cookies(x) & "<br>")
  end if
  response.write "</p>"
next
%>

</body>
</html>


Code:

Output:
firstname=Alex

user:firstname=John
user:lastname=Smith
user:country=Norway
user:age=25


Thanks

Reply With Quote
Reply

Viewing: Tutorialized ForumsWeb Design & DevelopmentASP > How to read and write cookies in ASP?


Developer Shed Advertisers and Affiliates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 

Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.

© 2003-2018 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap