Latest Cookies

Source: Internet
Author: User
So anyways, on to the code. The first thing we need to think of is exactly what data will need to be
Stored in the cookie. In this case we will use info submitted by the user via this form:

<Form action = "cookie. asp" method = "post">
<Input type = "text" name = "name" size = "20">
<Input type = "submit" value = "submit">
Now let's get to the fun part, setting the cookie info. You can use the following code to set the cookie
Value on the clients machine:

Response. buffer = True
'First we put the data from the form into a variable
Name = Request. Form ("name ")
'Then we can set the cookie value using this:
Response. Cookies ("name") = name
OK, so now the cookie is set and we need to retrieve the info. You can use this to retrive the cookie

'First we retrive the data and set it to a variable
Name = Request. Cookies ("name ")
'Then we post it to the website
Response. Write (name)
And it's that easy. But wait, there is more. There are a few properties that you can set using cookies.
The first property is the Domain property. This is the domain that the cookie originated from. The cookie
Can only be read by the domain it originated from. It is set by default to the domain in which it was
Created, but you can alter it for your needs. You can set it using this:

Response. Cookies ("name"). Domain = ""
The next important property is the Expires property. This specifies the date the cookie shocould expire. If
It is set to a past date then it will expire when the browser is closed.
When setting the date it can be set a couple of ways. You can use the current date and add or subtract

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.