External Popup Onclick To Open Only Once Per Session
Solution 1:
yes, you can do that using cookies .
php has functions for dealing with cookies , mainly setcookie() and companions
**/ Set a Cookie /*
add_action( 'init', 'set_mycookie' );
functionset_mycookie() {
setcookie( 'cookiename', 'cookievalue', time() + 3600, COOKIEPATH, COOKIE_DOMAIN );
}
**/ Get a Cookie /*
add_action( 'wp_head', 'get_mycookie' );
functionget_mycookie() {
$myvar= isset( $_COOKIE['cookiename'] ) ? $_COOKIE['cookiename'] : 'cookie not set';
}
**/ Delete or Unset /*
add_action( 'init', 'unset_mycookie' );
functionunset_mycookie() {
setcookie( 'cookiename', '', time() - 3600, COOKIEPATH, COOKIE_DOMAIN );
}
now, of course these are the most basic general examples, but you could use it with any set of conditions, ( like @Bibberty comment/question ) for example by session, by user, by day, by page, etc . whatever you want .
Sidenote - wp has dedicated functions for using cookies, mainly for auth and session management ( which wp does not do by default ). see wp_set_auth_cookie() to learn more
sidenote 2 Also, regarding your code ... embading php inside JS ( or viceversa...) is a bad practice. wp has actually a very cool and elegant function to deal with that, and if you really want to learn php/wp - you better start using it now
Solution 2:
Its done , I did a popup with a css class with a z-index, and I inserted a transparent image as a external link with _blank and onclick into body. Maybe unprofessional but functional
Solution 3:
you can do with partial javascript partial php,
1) Php Based Cookie - Session session check
2) Javascript : Cookie - LocalStorage based session check
Post a Comment for "External Popup Onclick To Open Only Once Per Session"