Results 1 to 10 of 10
Thread: ASP Cookies
-
ASP Cookies
What is a Cookie?
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.
How to Create a Cookie?
The "Response.Cookies" command is used to create cookies.
Note: The Response.Cookies command must appear BEFORE the <html> tag.
In the example below, we will create a cookie named "firstname" and assign the value "Alex" to it:
It is also possible to assign properties to a cookie, like setting a date when the cookie should expire:Code:<% Response.Cookies("firstname")="Alex" %>
Code:<% Response.Cookies("firstname")="Alex" Response.Cookies("firstname").Expires=#May 10,2012# %>
How to Retrieve a Cookie Value?
The "Request.Cookies" command is used to retrieve a cookie value.
In the example below, we retrieve the value of the cookie named "firstname" and display it on a page:
Output: Firstname=AlexCode:<% fname=Request.Cookies("firstname") response.write("Firstname=" & fname) %>
A Cookie with Keys
If a cookie contains a collection of multiple values, we say that the cookie has Keys.
In the example below, we will create a cookie collection named "user". The "user" cookie has Keys that contains information about a user:
Code:<% Response.Cookies("user")("firstname")="John" Response.Cookies("user")("lastname")="Smith" Response.Cookies("user")("country")="Norway" Response.Cookies("user")("age")="25" %>
Read all Cookies
Look at the following code:
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" %>
Assume that your server has sent all the cookies above to a user.
Now we want to read all the cookies sent to a user. The example below shows how to do it (note that the code below checks if a cookie has Keys with the HasKeys property):
Code:<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>
Output:
firstname=Alex
user:firstname=John
user:lastname=Smith
user:country=Norway
user:age=25
source: w3schoolsLast edited by learvy; 05-14-2011 at 06:03 PM.
-
05-14-2011 05:57 PM # ADSAdvertise here Circuit advertisement
- Join Date
- My Birthday
- Posts
- Million and counting
-
08-27-2012, 08:30 AM #2
Banned
This user has no status.I am:----
- Join Date
- Aug 2012
- Posts
- 463
- MTV$
- 1,116
Re: ASP Cookies
i think asp cookies is a each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.
-
09-03-2012, 04:11 PM #3
Banned
This user has no status.I am:----
- Join Date
- Aug 2012
- Posts
- 338
- MTV$
- 829
Re: ASP Cookies
I think that ASP cookies will identify the user name as well as its some feature The creating of cookies in ASP is very easy as well as it is very comfortable.We can create a cookies as example above shown in the posting.
-
09-09-2012, 06:27 PM #4
Banned
is who wander are lost!!!I am:
- Join Date
- Sep 2012
- Posts
- 1,704
- MTV$
- 5,031
Re: ASP Cookies
i think asp cookies is a each time the same computer requests a page with a browser, it will send the cookie too. With ASPI think that ASP cookies will identify the user name as well as its some feature The creating of cookies in ASP is very easy as well as it is very comfortable.
-
09-11-2012, 09:46 PM #5
MTV Regular
This user has no status.I am:----
- Join Date
- Sep 2012
- Posts
- 349
- MTV$
- 8
Re: ASP Cookies
i think asp cookies is a each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values. .We can create a cookies as example above shown in the posting.
-
09-14-2012, 12:54 AM #6
Banned
This user has no status.I am:----
- Join Date
- Sep 2012
- Posts
- 1,129
- MTV$
- 3,336
Re: ASP Cookies
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.
-
Re: ASP Cookies
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.
The "Response.Cookies" command is used to create cookies.
Note: The Response.Cookies command must appear BEFORE the <html> tag.
In the example below, we will create a cookie named "firstname" and assign the value "Alex" to it:
<%
Response.Cookies("firstname")="Alex"
%>
It is also possible to assign properties to a cookie, like setting a date when the cookie should expire:
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("firstname").Expires=#May 10,2012#
%>
-
10-04-2012, 10:25 AM #8
Banned
is is banned for copy pastingI am:----
- Join Date
- Oct 2012
- Posts
- 340
- MTV$
- 1,000
Re: ASP Cookies
A cookie is often used to identify a user.
A cookie is often used to identify a user. A cookie is a small file that the server embeds on the user's computer. Each time the same computer requests a page with a browser, it will send the cookie too. With ASP, you can both create and retrieve cookie values.
How to Create a Cookie?
The "Response.Cookies" command is used to create cookies.
Note: The Response.Cookies command must appear BEFORE the <html> tag.
In the example below, we will create a cookie named "firstname" and assign the value "Alex" to it:
<%
Response.Cookies("firstname")="Alex"
%>
It is also possible to assign properties to a cookie, like setting a date when the cookie should expire:
<%
Response.Cookies("firstname")="Alex"
Response.Cookies("firstname").Expires=#May 10,2012#
%>
-
11-29-2012, 10:06 AM #9
MTV Regular
This user has no status.I am:----
- Join Date
- Nov 2012
- Posts
- 323
- MTV$
- 863
Re: ASP Cookies
ASP Cookies can also be called as a thread which contains a small piece of information which refers to the username states the identity of the users who requests a web page.
-
Re: ASP Cookies
With the help of ASP, you can both create and retrieve cookie values.so it can also be called as a thread
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
































Reply With Quote



Bookmarks