I have an issue with <Cflocation> same code, same ...
# cfml-general
m
I have an issue with Cflocation same code, same variables same setup. Except one server is using CF2023 and the other CF2018, The cflocation tag works in CF2018 and redirects to where it needs to go but the same code in CF2023 returns a 302. Is there any reported issues with CF23 and cflocation ?
a
Returning a
302
is what
<cflocation>
does.
(https://helpx.adobe.com/coldfusion/cfml-reference/coldfusion-tags/tags-j-l/cflocation.html) Can optionally return a different 3xx status if told to do so.
🙏 1
So what exactly is the issue?
m
ok but on CF2023 its coming back to the sites login page and CF2018 is going to the website that the cflocation is supposed to go to. No diff in code, server settings nothing. So bizarre
a
<cflocation>
will send a status code (as above) and a
Location
header with a URL to redirect to. The browser will then... relocate to that URL. What URL is being sent to the browser? I suspect the problem is more "your code's logic is not giving
<cflocation>
the correct URL, for... [reasons]"
m
Yeah possibly code is same as CF2018 though exact same
a
OK, don't look for reasons why it should work. That won't get you very far. Look for reasons why it isn't working.
I would guess the logic relies on something in the environment or some other value that is somehow different on each server. Could be anything.
"the code is the same" is not the only factor in "what code does when it runs"
m
Yep agree. Ill have a dig around and see whats different on each environment. Cheers Adam
a
Follow the logic through... don't assume any variable values... check them.
☝️ 1
m
will do 🙂
d
Monitor the HTTP traffic using the Dev Tools. I suspect there's some differences in the URLs. Wasn't there a chance in behavior in the addtoken argument at some point?
a
But first verify my hypothesis that the
<cflocation>
and browser are doing exactly what they're supposed to, but it's that the code is giving
<cflocation>
the wrong URL
addtoken
changed ages ago. Like CF9 or something (don't quote me on that, but it was way back when I was still doing CF)
(and we were on CF9)
oopsy...
New in ColdFusion 11: If Secure Profile is enabled, addToken's default value will be false.
Still... don't think it'll contribute either way here
worth checking though
d
@Adam Cameron, Reading the docs, it defaults to "false" when the secure profile is enabled, so maybe in his 2018 environment it's still defaulting to "true"
That could explain why he ends up at a login screen.
a
no cookie.
m
No cookie! Hmm could be. Where is Secure profile set in the cfadmin ?
a
buuuuut... cookies should still go with the 302 response. Never really understood why CFML has that
addtoken
option..?
d
Well, unless something is going on and the cookies are persisting. Like maybe he's going from x.site.com to y.site.com or from a domain name to an IP, etc.
👍 1
a
yeah so @mauzer would the behaviour be - if the request is a new session - to bounce them to the login screen?
m
Yes correct it is
a
OK, so look at the network panel in dev tools. I bet your sessions aren't sticking
m
ok cool will check it
a
(probs cos the CFID bumpf is new each time)
m
so how do you prevent that happening ?
a
[this is beyond my recollections of how CF works. I've never had to deal with it, so never needed to find out / know]
👍 1
a
If you are changing subdomain on the redirect, if you look at the cookies in browser dev tools on the request is the domain set as
.<http://mydomain.com|mydomain.com>
or
<http://x.mydomain.com|x.mydomain.com>
?
👍 1
You'll also want to preserve network traffic in the dev tools or you won't see the request headers which do the 302 redirect request :)
m
ok @aliaspooryorik cheers im taking a look now 🙂
a
From what I vaguely recall (assuming that's the issue) - the I think you want be able to do something like this in your Application.cfc:
Copy code
this.sessioncookie.samesite = "Lax";
this.authcookie.samesite = "Lax";
🙏 1