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

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.

This script will save all of your form fields in a cookie. It includes all text fields, radio button selections, checkbox values, etc. When your visitor returns, all form fields are automatically repopulated with the same value that they entered on their last visit.

This search box is a small compact search engine give your visitors something to come back for.

Type whatever you like in the boxes, click outside the box, reload the page, and try to type the details again. This script uses cookies, so if you have them disabled it will of course not work.

Catches all clicks on ads and writes a cookie on the visitor’s computer. Until the cookie expires, no ads are shown. Cool!

If you have a popup window which opens on your home page every time a visitor returns, it can become very annoying. Using cookies, this script can determine if the visitor has been here before, and only open a new window on their first visit to the page. The next time they come back, the script will read the cookie, identify them as a repeat visitor, and not open the window again.

Use this cookie to show your visitors what’s new on your Web site since their last visit.

“A Notepad that will “”Take a note”” and display it when visitor visits site next time. Perfect for start pages. (Hey! Try this: Add some notes, restart computer, then restart script!)”

Want a cool cookie script, but hate pop-up prompt boxes? Here’s your solution! This professional looking, highly customizable script saves the value of an input box. It can be used in many ways and it’s all annotated in the script, so you can easily see how it works. If you like it, nominate it! It’s my first script!

This cookie records the visitor’s name. It can then be used for identification or other purposes, as needed.