The Mailster Cookie

Whenever a subscriber clicks a link in a campaign, Mailster sets a cookie on your domain to identify the user at a later point. This is required as often the subscriber doesn’t have an account on your site or is not logged in.

The cookie stores the hash of the subscriber, which is a random string generated during the creation of the entry of subscriber in the database.

The name of the cookie is “mailster” and is stored in the path defined by COOKIEPATH and assigned to the domain stored in COOKIE_DOMAIN.

By default, the cookie expires one hour after the last click within a campaign. You can, however, use a filter to extend this time or disable the cookie completely:

add_filter( 'mailster_cookie_time', function( $timeout ){

     return MONTH_IN_SECONDS;

});

The cookie is created with PHP’s setcookie method. There’s no JavaScript used at any point.

setcookie( 'mailster', $hash, time() + $cookietime, COOKIEPATH, COOKIE_DOMAIN );

If either mailster_get_current_user() or mailster_get_current_user_id() is used, Mailster first checks if this cookie is set.