PC SOFT

WINDEVWEBDEV AND WINDEV MOBILE
ONLINE HELP

Home | Sign in | English UK
  • This lesson will teach you the following concepts
  • What is a cookie?
  • What is a cookie made of?
  • Practical example
  • How to use the cookies?
Lesson 7.2. The cookies
This lesson will teach you the following concepts
  • What is a cookie?
  • How to manage the cookies?

Estimated time: 10 mn
Previous LessonTable of contentsNext Lesson
What is a cookie?
A cookie is an easy way to temporarily store an information on the computer of Web user. This information can be read again later by the site that created it.
This allows you to avoid asking for details already supplied during a previous visit and to propose custom pages

Internet

A cookie has an expiration date (30 days after its creation by default). It is automatically destroyed by the browser of Web user when its lifetime is exceeded.
Caution: using cookies is possible only if the browser of Web user is configured to accept cookies.
A cookie is used to store on the computer of Web user various information such as the user name, the pages displayed by the user, the date of his last connection, the backup of his options, ...
This information, saved in the format of cookies, will be read by the site during the next connection of Web user. Therefore, the site will be able to propose custom information to the user:
  • advertising banner related to subjects looked up during the last connection,
  • custom home page with the user name and the date of last connection,
  • special offers corresponding to the searches performed during the last visit, ...

Note

The cookies are not encrypted when they are stored: we advise you not to use them to store sensitive information.

What is a cookie made of?

A cookie is a text file stored on the computer of Web user (in most cases, in the Internet "cache" of browser) during a specific duration. The cookie is created by the browser or by the server.
The following elements are required to store information in a cookie:
  • Name of cookie, used by the site to identify the cookie.
  • Text of cookie, corresponding to the information written by the site: pages displayed, details supplied by the Web user, ...
  • Expiration date after which the cookie is not valid anymore (it will be automatically deleted).
  • Name of Internet domain that created the cookie.

Practical example

  • To check the management of cookies, we are going to import the unit example named "The cookies" into the "Full_WEBDEV_Site" project.
  • To open a unit example:
    1. Display the WEBDEV home window (Ctrl <).
    2. Click "Open an example".
    3. In the search control, type "Cookies". The unit example named "The Cookies" appears in the window.
    4. Click the name of unit example.
    5. The page corresponding to the unit example is displayed in the editor.
    6. Save the page.
How to use the cookies?
The cookies can be used according to two different modes:
  • The cookies used in Server code.
  • The cookies used in Browser code.
To use the cookies, WEBDEV includes 2 functions that can be used both in server code and in browser code:
  • CookieWrite: is used to send a cookie when displaying the HTML page in the browser of Web user.
  • CookieRead: is used to retrieve the value of a cookie saved on the computer of Web user.
The "PAGE_Cookies" example page presents an example for reading and writing a cookie in server code and in browser code.
See Managing cookies for more details.
Previous LessonTable of contentsNext Lesson
Minimum version required
  • Version 23
Comments
Click [Add] to post a comment