FREE tutorial,solution,RSS Feeds on Operating Systems, Programming, Web Development, Applications, Databases, Networking, Hardware, Security, SEO Free Expertsforge Membership
Join us as Moderator
Submit Article to Expertsforge.com Submit Article My Expertsforge
 
RSS Feeds, Help Help RSS Feeds
bannertop
 

ASP Tutorial: Creating & Retrieving Cookies using ASP

jawahar
4/2/2005 3:56:15 PM, Views: 1443
This tutorial show how to create & Retrieve cookies using ASP.

<%
Response.Cookies("Expertsforge")=1
Response.Cookies("Expertsforge").Expires="June 15, 2005"
%>

By adding this code to the top of your page you will drop a cookie on the
client. One way to use this is to determine if a user has been to your
site before. This cookie is set to expire on June 15 2005.

Now if you want the cookie to expire when they leave just dont give it an
expiration like so:

<%
Response.Cookies("Expertsforge")=1
%>

Heres how to read the cookie and use it to display a greeting:

<%
If Request.Cookies("Expertsforge") = 1 Then
greet = "Welcome Back To Expertsforge"
Else
greet = "Welcome To Expertsforge!"
End If
Response.Write greet
Response.Cookies("Expertsforge")=1
Response.Cookies(Expertsforge").Expires="June 15, 2005"
%>

Now you will note that I set the cookie AFTER I checked for it. This is
because if we write the cookie before checking, it would always say
Welcome Back.

Theres the basic recipe for cookies.
Next Steps:
Add this Tutorial to:
Blink Blink del.icio.ous Del.icio.us Digg Digg
Fark Fark Furl Furl Google Google
Reddit Reddit Simpy Simpy Spurl Spurl
Technorati Technorati Windows Live Win Live Yahoo Yahoo
Rate Me!
Not Yet Rated!
Rate:
Send Private MessageSend Message
Signup / Login To View the Solution or Provide Comments
Post Comment/Solution
Comment:*
        (Link Rules) 
  Use : [bold] for <b>; [/bold] for </b>; [italic] for <i>; [/italic] for </i>; [code] & [/code] for code
 
Categories
Options
ASP RSS Feed
Most Popular Tutorial
Most Popular Solution
Top Rated
Top Contributors
Yearly
Overall
 
1. jawahar (200)
bnrtop