Cookie scope doesn't throw error while inserting struct directly


#1

Issue happened on latest version of lucee & ACF also, It does not throwing any exception while write a struct directly to a cookie in the cookie scope. I’m checked with ACF11, ACF16 acts same way as lucee does.

Sample code :
variables.someStruct = {
‘Squirrels’: ‘Are totally cool’
};
cookie.squirrel_plain = variables.someStruct;
writeDump(cookie);

ACF returns :
[empty string]

Lucee returns :
Empty:null

If we add complex objects for array and query related value in cookie, it works fine but still fails for Struct.

Use Array to cookie :
Can’t cast Complex Object Type Array to String

Use Query to cookie :
Can’t cast Complex Object Type Query to String

Source : https://luceeserver.atlassian.net/browse/LDEV-942

Trycf sample: http://trycf.com/scratch-pad/gist/9963e4742554ffe1f083e12bfc70eeed

Please give any suggestions about this.


#2

I have read the linked ticket and noticed Michael’s request for user comment. I can see that changing behaviour could possibly break existing code. However, I can’t quite think of why not failing would be benefit the user or be expected in any possible workaround that someone might have written in their app.

If you write to the cookie scope I think you are probably expecting to read that value as some point in the future and it’s not going to be available.