It's Sean!

UK freelance journalist, author
and writer Sean McManus

Printed from www.sean.co.uk. © Sean McManus.

NEW: Sign up for my newsletter!

Home > Articles > Webmaster resources > Javascript Toolkit > Javascript examples > Cookies

The Javascript smart marketing toolkit

Javascript cookies tools

The cookies functions will enable you to store data in a cookie and recall it later.

As well as providing routines to enter data in a cookie against a keyword you specify and recall it later using the same keyword, the toolkit provides for several interest counters to be maintained. By default there are seven, but you can add more by editing the toolkit's code.

These interest counters can be used to keep a track of what your visitor is most interested in on your site - which links they follow and which areas of the screen they mouseover. You can use this information to tell them about what's new in the areas they frequent or to try to entice them to sections they rarely visit.

Interactive demonstration

Please enter your name:

What is your best friend's name?

When is their birthday?
(tip: if it's tomorrow, you'll get a special message)
Date:
Month:

What is your friend most interested in? Music Books Videos

Now click here to see a demonstration of recovering that information.

Overview of Javascript cookie routines

Table explaining cookie management functions of the toolkit
function what it does
set_up() The set_up() routine must be run when the page loads.
poke_cookie(name,value) This routine is used to store any value you like in the cookie, together with a name you can use to recall it again. The demonstration files show how this can be used to ask someone's name and store it in the cookie.
peek_cookie(name) This routine is used to recover the information you've stored in the cookie, using the same name as used with poke_cookie().
delete_banner_cookie() This will clear the cookie.
interest_increase(interestnumber)

interest_decrease(interestnumber)

These routines will increase and decrese the counter number given in brackets. The counters must be configured by editing the code in the set_up() routine.
interest_enquire(interestnumber) Returns the current total for the interest number requested in brackets.
most_interested() Reveals the interest with the highest counter level.
least_interested() Reveals the interest with the lowest counter level.

Cycling banner advert

See the page on banner cycling features of the toolkit for more information on what this is doing and how it works.

Navigating the toolkit:

Books by Sean McManus

Scratch Programming in Easy Steps

Scratch Programming in Easy Steps

Raspberry Pi For Dummies

Raspberry Pi For Dummies

Learn to program with the Scratch programming language, widely used in schools and colleges.

Set up your Pi, master Linux, learn Scratch and Python, and create your own electronics projects.

Coder Academy

Coder Academy

Cool Scratch Projects in Easy Steps

Cool Scratch Projects in Easy Steps

Learn to make games and other programs in Scratch 2.0, and make a web page in HTML, with this highly interactive book for 7-10 year olds.

Discover how to make 3D games, create mazes, build a drum machine, make a game with cartoon animals and more!

More books

Recommended articles

Stylised coloured photo of a synth

Discover my music and home recording articles

Interested in starting home recording? Follow me as I start recording, using instruments such as the Novation MiniNova and Korg Kaossilator, and share my synth and sample-based music online.

Scratch cat and rainbow circle

10-block demos for Scratch programming

Lots of people of all ages are learning to program with Scratch. Discover some useful tricks and techniques in my 10-block Scratch demos, including special effects you can drop into your games.

Paper Raspberry Pi case

Download free book chapters and more!

Download a free case for your Raspberry Pi, and free chapters from my books about the Raspberry Pi, Scratch, web design and more!

©Sean McManus. www.sean.co.uk.