0

A persistent cookie (x1st) is dropped straight away when a user lands on my site with a unique value (of whatever 'hdflashfafafxx233ddd').

This cookie is used for tracking, but if the user opts out of tracking cookies I need to set this value to 0 - I cannot delete it as this is cookie reset constantly.

I then need to expire x1st with the value of 0 when user opts back in.

  //cookie set by server
  $.cookie('x1st', 'hdflashfafafxx233ddd', { path: '/', domain: mysite.co.uk });

  //changing value of cookie when user opts out 
  $.cookie('x1st', 0, {path: '/', domain: mysite.co.uk });

  //expire cookie when user opts back in 
  $.cookie('x1st', 0, { expires: -1 , path: '/', domain: mysite.co.uk });

The problem is I am unable to change the value of the x1st cookie to 0

4

1 に答える 1

1

の文字列値である必要があります'0'。整数ではありません。Cookie は文字列のみを保存します。

于 2012-09-14T15:39:49.287 に答える