Ben May

Ben is Managing Director of The Code Company. He works with prospective and current clients to develop innovative solutions.

Setting a cookie & showing a popup to mobile users w/ jQuery

I needed to have a quick popup that only showed to iOS devices that suggested they download the app for the website, and set a cookie to only show this popup once a month.

Doing PHP detection of cookies and browsers gets tricky and takes a bit more time to setup when you have layers of cache infront.

I was surprised to be able to do this all with Javascript / jQuery. I was able to leverage an existing jQuery plugin that takes care of the cookie stuff, called jQuery Cookie. Otherwise, just a little bit of javascript to detect the browser and we’re set!