Case: User clicks on an image
- If it is a returning user (user session valid for 30 minutes) navigate to the link of the image
- If it is a new user show a pop-up div
I am now showing the pop-up div whenever the image is being clicked. Any advice on how to save the session and refer it as the variable in a JavaScript to perform a function like:
if {
// user is log in.. do your task here..
} else {
//user is not log in.. do your task here...
}
EDIT:
<script>
<? if(isset($_SESSION["logged_in"])) {
echo "var $check=1";
} else {
echo "var $check=0";
} ?>
function SetMood() {
if($check==1) {
// user is log in.. do your task here..
alert('URL');
} else {
//user is not log in.. do your task here...
document.getElementById('light').style.display='block';
document.getElementById('fade').style.display='block';
document.getElementById('fade').scrollIntoView(true);
}
}
</script>
This is called for the image as:
<a id="register" href = "javascript:void(0)" onclick = "SetMood();" data-fancybox-group="gallery">
<img src="<cms:show my_image_thumb />" alt="" class="fade">
</a>
The above has no effect and now nothing opens onClick