Skip to content

Commit

Permalink
COLDBOX-537
Browse files Browse the repository at this point in the history
ColdBox Cache Flash not discovering session/cookie as app has not loaded first
  • Loading branch information
lmajano committed Aug 11, 2016
1 parent 0ca41c2 commit 116f1f0
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions system/web/flash/ColdboxCacheFlash.cfc
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,13 @@ component extends="coldbox.system.web.flash.AbstractFlashScope" accessors="true"
property name="cacheName";
// The cache provider
property name="cache";
// The flash key
property name="flashKey";

/**
* Constructor
* @controller.hint ColdBox Controller
* @defaults.hint Default flash data packet for the flash RAM object=[scope,properties,inflateToRC,inflateToPRC,autoPurge,autoSave]
*/
function init( required controller, required struct defaults={} ){
// init flash key
variables.flashKey = "";
// default cache name
variables.cacheName = "default";
// super init
Expand All @@ -42,34 +38,25 @@ component extends="coldbox.system.web.flash.AbstractFlashScope" accessors="true"
* Build Flash Key according to standards
*/
function getFlashKey(){
// Lazy Loaded, waiting for sessions to exist.
if( !len( variables.flashKey ) ){
lock name="cacheflash-#controller.getAppHash()#" type="exclusive" timeout="30" throwOnTimeout="true"{
if( !len( variables.flashKey ) ){
// Check jsession id First
if( isDefined( "session" ) and structKeyExists( session, "sessionid" ) ){
variables.flashKey = "cbox_flash_" & session.sessionid;
}
// Check normal cfid and cftoken in cookie
else if( structKeyExists( cookie, "CFID" ) AND structKeyExists( cookie,"CFTOKEN" ) ){
variables.flashKey = "cbox_flash_" & hash(cookie.cfid & cookie.cftoken);
}
// Check normal cfid and cftoken in URL
else if( structKeyExists( URL, "CFID" ) AND structKeyExists( URL,"CFTOKEN" ) ){
variables.flashKey = "cbox_flash_" & hash( URL.cfid & URL.cftoken );
}
// check session URL Token
else if( isDefined( "session" ) and structKeyExists( session, "URLToken" ) ){
variables.flashKey = "cbox_flash_" & session.URLToken;
} else {
throw( message="Cannot find a jsessionid, URLToken or cfid/cftoken in the cookie scope. Please verify",
type="ColdboxCacheFlash.CFIDException");
}
}
}
// Check jsession id First
if( isDefined( "session" ) and structKeyExists( session, "sessionid" ) ){
return "cbox_flash_" & session.sessionid;
}
// Check normal cfid and cftoken in cookie
else if( structKeyExists( cookie, "CFID" ) AND structKeyExists( cookie,"CFTOKEN" ) ){
return "cbox_flash_" & hash(cookie.cfid & cookie.cftoken);
}
// Check normal cfid and cftoken in URL
else if( structKeyExists( URL, "CFID" ) AND structKeyExists( URL,"CFTOKEN" ) ){
return "cbox_flash_" & hash( URL.cfid & URL.cftoken );
}
// check session URL Token
else if( isDefined( "session" ) and structKeyExists( session, "URLToken" ) ){
return "cbox_flash_" & session.URLToken;
} else {
throw( message="Cannot find a jsessionid, URLToken or cfid/cftoken in the cookie scope. Please verify",
type="ColdboxCacheFlash.CFIDException");
}

return variables.flashKey;
}

/**
Expand Down

0 comments on commit 116f1f0

Please sign in to comment.