Cookies JavaScript Code Snippets

These snippets all create JavaScript Cookies. Cookies are small bits of information such as a name, a date, an order, etc. JavaScripts can set cookies on a user’s hard drive and retrieve them later, when needed.

Results via Envato Market

This cookies records how many times the visitor has visited the page and writes to the page accordingly.

This cookie displays a welcoming message to the user displaying the date and time of their last visit.

“Allows you to put a visitor’s name on the page without using cookies. If they don’t enter anything or press cancel they are designated “”anonymous jerk”” – or whatever you want!”

This cookie records the number of visits, and displays a message showing how many visits have been recorded.

Verifies that user filled in form on your main screen before proceeding to any other pages on your site. If user tries to click on link to another page, redirects them to main form for sign-in.

Paste in the src of this script anywhere in your page to use it! Each visitor will have their visits counted separately.

Easy to use! A sequential quotaion is shown every time the page is displayed. There’s no code to change, just insert strings for your quotes (w/ cookies). The script uses a cookie, to remember between visits where it’s been in the list. Unlike using random numbers, the user will see all the quotes before they start to repeat. This script uses the construction method to dynamically create an array of objects and the array.length property so the script user doesn’t have to worry about the number of elements or finding all the locations of specific constants.