Created
September 13, 2020 11:52
-
-
Save bennadel/b0bf2ae541294f8938b9856fa8d67313 to your computer and use it in GitHub Desktop.
The First Cookie Wins When Conflicting Cookie Names Are Used With Different Settings In Lucee CFML 5.3.6.61
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
param name="url.type" type="string" default="full"; | |
if ( url.type == "full" ) { | |
cookie[ "benben" ] = { | |
value: "woot woot (for .projects.local.invisionapp.com)", | |
domain: ".projects.local.invisionapp.com", | |
secure: true, | |
preserveCase: true, | |
expires: "never" | |
}; | |
} else { | |
cookie[ "benben" ] = { | |
value: "woot woot (for .local.invisionapp.com)", | |
domain: ".local.invisionapp.com", | |
secure: true, | |
preserveCase: true, | |
expires: "never" | |
}; | |
} | |
</cfscript> | |
<!--- | |
After we SET the cookies on the ColdFusion Response, let's see how they present on | |
the Client-side in JavaScript. | |
---> | |
<script type="text/javascript"> | |
for ( var cookie of document.cookie.split( /;\s*/g ) ) { | |
var pair = cookie.split( /=/ ); | |
if ( pair[ 0 ] === "benben" ) { | |
console.log( pair[ 0 ], ":", decodeURIComponent( pair[ 1 ] ) ); | |
} | |
} | |
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
dump( cookie ); | |
</cfscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfscript> | |
cookie[ "benben" ] = { | |
value: "", | |
domain: ".local.invisionapp.com", | |
secure: true, | |
preserveCase: true, | |
expires: "now" // Setting the OLD cookie, at less-specific domain, to expire. | |
}; | |
cookie[ "benben" ] = { | |
value: "woot woot (for .projects.local.invisionapp.com)", | |
domain: ".projects.local.invisionapp.com", | |
secure: true, | |
preserveCase: true, | |
expires: "never" | |
}; | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment