Title: coldfusion session storage setting from memory to redis not working as expected
Tags: redis;coldfusion
Question: I have a very simple script that increments session variable in loop with a sleep 1 second call in it.
On status.cfm I dumped the session variable and I can see its incrementing; by refreshing the page time to time.
But when I change session management from memory to redis then what happens is that the session doesn't increment in loop and when the script ends then at that point it store the last value of loop. So if on status.cfm page if I keep refreshing it doesn't reflect changes until the loop script is finished and show last value only, which doesn't server my purpose of monitoring changes to session.
index1.cfm
<cfloop index="i" from="1" to="10"&gt;
<cfscript&gt;sleep(1000)</cfscript&gt;
<cfset session.counter.foo = i&gt;
</cfloop&gt;
<cfdump var="#session.counter#"&gt;
status1.cfm
Checking status...
<cfdump var="#session.counter#"&gt;
Same scenario as point one, but this time for a thread.
And the issue is the tread result doesn't get saved in session and gives the  following message instead of thread result object.
coldfusion.runtime.SessionScope$Serialization Problem
index2.cfm
Setting Threads struct {foo="bar", details={}}....
<cfset session.threads_foo = "bar"&gt;
<cfset session.thread_details = structNew()&gt;
Creating Thread and dumping....
<cfthread action="run" name="thread01"&gt;
<cfscript&gt;sleep(2000);</cfscript&gt;
<cfset thread.j=1&gt;
<cfloop index="i" from="1" to="999999"&gt;
<cfset thread.j=thread.j+1&gt;
</cfloop&gt;
</cfthread&gt;
<cfset session.thread_details = thread01&gt;
Dumping session variable...
<cfdump var="#session#"&gt;
[DONE]<br&gt;<br&gt;
status2.cfm
Checking status session threads status...
<cfdump var="#session#"&gt;
In PHP there is session_write_close() function that closes the file lock of session so it doesn't wait for the script to end and session file is available to access. Is there anything in coldfusion like that? I'm not sure even if such function exist it would help on redis session which is already a memory storage and not file.
please guide
Comment: @Miguel-F I read that page but it doesn't help with the issue I'm facing, it just tells how to configure it and its benefits. Some insight would really help me.

Comment: @Miguel-F, you are right, and I read that part & was afraid of. Which is why I added the last note related to php function that closes session file. So far i didn't found a way to persist changes as soon they update. Which is what I hope to achieve, Maybe I can't achieve this with redis session?

Comment: Here is some information that might help you - [External session storage](https://helpx.adobe.com/coldfusion/using/external-session-storage.html)

Comment: Points that I thought might be relevant. "_If you select Use J2EE session variables, you cannot store ColdFusion sessions in Redis._" and "_If the nodes in a cluster use Redis, disable sticky sessions at the load balancer. In addition, clear the Sticky Sessions and Session Replication check-boxes in Cluster Manager._" and "_The session is persisted (if modified) back to external storage **on request end**._"



{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 0, 'CommentCount': 4, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2020:00:04/08/20', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<redis><coldfusion>', 'Title': 'coldfusion session storage setting from memory to redis not working as expected', 'ViewCount': 352, 'id': 61103252, 'user_AboutMe': "<p>Web Developer since 2012. Latest technologies, the way it's shaping and helping the future of mankind fascinates me. This gives me inspiration to code.</p>\n", 'user_AccountId': 1783912.0, 'user_DisplayName': 'Abdul Rehman', 'user_Reputation': 1558.0, 'user_Views': 347.0, 'user_id': 4311336.0}}