I agree popup then enable function

I agree popup then enable function

Hi 

I want  to enable a function (or to load a js file in the head) only after a popup open and the condition (I agree) are accepted (onclick)

how can I do it ?  (stored in cookies or session ?)

thank you