Skip to content

Commit

Permalink
Merge pull request #3 from Constructor-io/ch1896/cookie-ttl
Browse files Browse the repository at this point in the history
[ CH 1896 ] Change Cookie TTL to 1 year
  • Loading branch information
rubikzube authored Jun 28, 2018
2 parents 8aee938 + 1da1b06 commit f8eef6e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/constructorio-id.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
cookie_name: 'ConstructorioID_client_id',
cookie_prefix_for_experiment: 'ConstructorioID_experiment_',
cookie_domain: null,
cookie_days_to_live: 365,
on_node: typeof window === 'undefined',
session_is_new: null
};
Expand Down Expand Up @@ -46,7 +47,8 @@

ConstructorioID.prototype.set_cookie = function (name, value) {
if (!this.on_node && this.persist) {
var cookie_data = name + '=' + value + '; expires=Tue, 19 Jan 2038 03:14:07 GMT; path=/';
var expires = new Date(Date.now() + this.cookie_days_to_live * 24 * 60 * 60 * 1000);
var cookie_data = name + '=' + value + '; expires=' + expires.toUTCString() + ' path=/';
if (this.cookie_domain) {
cookie_data += '; domain=' + this.cookie_domain;
}
Expand Down

0 comments on commit f8eef6e

Please sign in to comment.