Sahil Dhir
Sahil Dhir

Reputation: 4250

Set cookie to a div that is shown after few second of video play?

I have a div element that shows up after 20 second of video play.If you will play the video after 20 second of play a div will shows up. Now I want to set cookie so that if the div have been shown once ,it keeps on showing unless the user clear the cache (cookie logic).

This is what I have tried so far - 

http://jsfiddle.net/9L29o365/

How can this be achieved?

Thanks In Advance .

Upvotes: 1

Views: 49

Answers (2)

mrtig
mrtig

Reputation: 2267

You could set the cookie in your onPlayProgress function, and read the same cookie handle in your click play listener:

// set 
document.cookie='20secSet=true';
// get
var cookieVal =  document.cookie
                         .split(',')
                         .indexOf('20secSet=true');

Here's an example using your code.

Upvotes: 0

Amal
Amal

Reputation: 3426

Try this code

set cookie

Cookies.set('div-20sec', 'visited');

get cookie

var val=Cookies.get('div-20sec');

DEMO

Upvotes: 1

Related Questions