Page Initialisation - Cookie Detection
We're looking at implementing a page initialisation script in our environment which detects users who happen to have our SSO cookie present but not the lithium cookie used to indicate the user is logged in.
The reason for this is that we find users who log into other SSO enabled sites/services then navigate to the community are logged in to SSO but not the community.
Users detected in this scenario would be redirected through our SSO login page which would drop the required lithiumSSO cookie and bounce the user back to the community to sign them in.
We've not had much luck creating a page initialisation script in our stage environment so far and are wondering where we're going wrong.
Conditions: User must have a cookie with the name "mainsiteSSO" is present and the community must still see the user as anonymous.
Action: redirect the user through the SSO login page for the community.
Current code:
<#assign has_sso_cookie = response.cookies.name.get("mainsiteSSO") />
<#if user.anonymous && has_sso_cookie == "true" >
${http.response.setRedirectUrl(webUi.getUserLoginPageUrl)}
</#if>
Any help would be greatly appreciated.
Thanks,
Rob
What error do you get?
You could also try getting the cookie via http.request.cookies:
<#assign has_sso_cookie = http.request.cookies.name.get("mainsiteSSO") /> <#if user.anonymous && has_sso_cookie?? > ${http.response.setRedirectUrl(webUi.getUserLoginPageUrl)} </#if>