I've been unable to figure out the right way to implement this mainly because of syntax issues as I'm fairly new to all of this.
I'd like to check if a user has been to a certain page (page2). I've got this script:
<script>
$.cookie('visitPage2', true, { expires: 365 });
</script>
My first question is:
Will that immediately run once the page is loaded? That is the entirety of JS on that page. Back on my homepage I'm running this script to change an image from displaying a lock to displaying the actual image instead. (but I know my syntax isn't right):
<script>
if (!$.cookie('visitobj1')){
$( ".swap1" ).toggleClass( "lock unlock" );
};
</script>
I had previously checked to see if my toggleClass was by just testing it with a click instead of uploading to the server to test cookies and it worked perfectly:
<script>
$( ".swap" ).click(function() {
$( ".swap" ).toggleClass( "lock unlock" );
};
</script>
Any help is much appreciated! Thanks!
(Just a quick summary in case I have been too wordy. I want to check if a user has been to Page2. If they have I want the homepage to display a new image instead of the usual lock image, which is changed using toggleClass)
Cookie.js documentation is here: https://github.com/js-cookie/js-cookie