Getting started
Check the session without redirecting
Example of how to query the session with user() and handle the signed-out state in your own interface, without starting the automatic redirect.
1 min read
requireUser() starts the redirect to the login page when there is no session. That is not always what you want: on a public page, for example, you usually just need to know whether the visitor is signed in and adapt the interface. For that, use user(), which only queries the session and never redirects.
Example
html
<script src="https://cdn.infinity6.ai/releases/sdkweb/latest/bundle/i6sdk-web.js"></script>
<script type="module">
const sdk = window.I6Sdk;
async function main() {
const user = await sdk.auth().user();
if (user) {
// Active session: show the signed-in area.
document.querySelector("#signed-in-area").hidden = false;
} else {
// No session: show a login button instead of redirecting.
document.querySelector("#login-button").hidden = false;
}
}
main();
</script>Points of attention
user()returnsnullwhen there is no session, without starting any redirect — your page decides what to do next.- If login is mandatory in some flow, switch from
user()torequireUser()only in that flow. - The call depends on third-party cookies between your page and the platform; see the per-browser limitations in Cookies and CORS.
Full reference
Support
Implementation support
Official channels for questions during integration.
Response within 1 business day
Technical support email
Send implementation questions with the context of your current step.
Coming soon
Direct assistance for quick integration questions.
Coming soon
Support assistant
i6 documentation and implementation assistant.
