Skip to main content
100%

Gist 50f16a9f81d9c88a6a48

✓ Published0🌍 Public
LLayne Smith
Last edited Apr 23, 2015
Created on Apr 23, 2015

This example demonstrates a cookie-based voting system that tracks whether a user has visited a page or submitted a vote. On page load, it checks for an existing "username" cookie; if none exists, it prompts for a name and stores it for 30 days. The code uses the jQuery Cookie plugin to set a per-page cookie after voting, triggering a welcome message on first visit or an already-visited alert afterward. It also includes native JavaScript functions (`setCookie`, `getCookie`, `checkCookie`) for manual cookie management, relying on `document.cookie` and `toGMTString` for expiration handling.

AI-generated description

Similar vizzes