antsanchez / cookie.js

Simple JavaScript code to set a cookie and write the value somewhere

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

cookie.js

Simple JavaScript code to set a cookie and write the value somewhere

Use

Link the script cookie.js.
Call the function writeCookieOnPlace(name_of_the_cookie_or_parameter, name_of_the_input_place_id) to:

  1. Check for the given paramenter or cookie. If the parameter exists, the cookie is saved (overwritten if exists).
  2. The value of the cookie is saved to the input with the selected id

Example

writeCookieOnPlace('affiliate', 'affiliateName')

  1. The code above will look for the parameter "affiliate" on the URL, like: http://yourweb.com/?affiliate=12345
  2. If if exists, will save the value to a cookie with the name "affiliate". If a cookie already exists with that name, it will be overwritten.
  3. If the parameter or the cookie exists, the value will be written on the value of the input field with the id 'AffiliateName'

About

Simple JavaScript code to set a cookie and write the value somewhere


Languages

Language:JavaScript 100.0%