1212 * information: "Portions copyright [year] [name of copyright owner]".
1313 *
1414 * Copyright 2011-2016 ForgeRock AS.
15+ * Portions copyright 2020-2026 3A Systems LLC.
1516 */
1617
1718define ( [
@@ -31,22 +32,25 @@ define([
3132 * @param {String } [path] - cookie path.
3233 * @param {String|String[] } [domain] - cookie domain(s).
3334 * @param {Boolean } [secure] - is cookie secure.
35+ * @param {String } [sameSite] - same site attribute.
3436 * @returns {String } created cookie.
3537 */
36- obj . createCookie = function ( name , value , expirationDate , path , domain , secure ) {
38+ obj . createCookie = function ( name , value , expirationDate , path , domain , secure , sameSite ) {
3739 var expirationDatePart ,
3840 nameValuePart ,
3941 pathPart ,
4042 domainPart ,
41- securePart ;
43+ securePart ,
44+ sameSitePart ;
4245
4346 expirationDatePart = expirationDate ? ";expires=" + expirationDate . toGMTString ( ) : "" ;
4447 nameValuePart = name + "=" + value ;
4548 pathPart = path ? ";path=" + path : "" ;
4649 domainPart = domain ? ";domain=" + domain : "" ;
4750 securePart = secure ? ";secure" : "" ;
51+ sameSitePart = sameSite ? ";SameSite=" + sameSite : "" ;
4852
49- return nameValuePart + expirationDatePart + pathPart + domainPart + securePart ;
53+ return nameValuePart + expirationDatePart + pathPart + domainPart + securePart + sameSitePart ;
5054 } ;
5155
5256 /**
@@ -56,18 +60,19 @@ define([
5660 * @param {Date } [expirationDate] - cookie expiration date.
5761 * @param {String } [path] - cookie path.
5862 * @param {String|String[] } [domain] - cookie domain(s). Use empty array for creating host-only cookies.
63+ * @param {String } [sameSite] - cookie same site attribute.
5964 * @param {Boolean } [secure] - is cookie secure.
6065 */
61- obj . setCookie = function ( name , value , expirationDate , path , domains , secure ) {
66+ obj . setCookie = function ( name , value , expirationDate , path , domains , secure , sameSite ) {
6267 if ( ! _ . isArray ( domains ) ) {
6368 domains = [ domains ] ;
6469 }
6570
6671 if ( domains . length === 0 ) {
67- document . cookie = obj . createCookie ( name , value , expirationDate , path , undefined , secure ) ;
72+ document . cookie = obj . createCookie ( name , value , expirationDate , path , undefined , secure , sameSite ) ;
6873 } else {
6974 _ . each ( domains , function ( domain ) {
70- document . cookie = obj . createCookie ( name , value , expirationDate , path , domain , secure ) ;
75+ document . cookie = obj . createCookie ( name , value , expirationDate , path , domain , secure , sameSite ) ;
7176 } ) ;
7277 }
7378 } ;
0 commit comments