I set up 2 variables in the cookie manager at the login page, the first is email, and the second is token.
When user logs in successfully, the login API returns the following:
{
"userId": 3,
"displayName": "[user name here]",
"accessToken": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzaWQiOiIwOGQ4MmVlNGRhNjEwNDExYjNjYzdlMWY0ODVmYzJlNyIsInJvbGUiOlsiUmVnaXN0ZXJlZCBVc2VycyIsIlN1YnNjcmliZXJzIiwiVXNlcnMiXSwiaXNzIjoicGxhbnRhbmFwcC1tZWRpY29udHJvbC5hcHBzLnBsYW50YW5hcHAuY29tIiwiZXhwIjoxNTk1NDk3NTcyLCJuYmYiOjE1OTU0OTM2NzJ9.xCccHAR37pRnESRsmwayDVa0kcFbG5m-Ltu4mfgAeIw",
"renewalToken": "o1gWnayGGctCBCGQYYcFvIZYrbkR1JiyUxvWEQUZc2NmyGczldEovRhGI0HYUcDV"
}
I want to pass the accesstoken value to other pages, because this token will be used as an input to other APIs that will display the data based on user access that is defined.
On successful server connect event, I created 3 events, set the email cookie value to the email input field, set the token cookie value to the access token returned by the login API, and redirect user to dashboard page.
<dmx-serverconnect id="sc_login" url="api/User/login" noload="noload"
dmx-on:success="cookies1.set('token',sc_login.data.apiSecurity.data.accessToken,{});cookies1.set('email',email.value,{});text1.setValue(sc_login.data.apiSecurity.data.accessToken)">
On dashboard page, I created the variables for the cookies with the same names, and then in the title of the page, I inserted the cookie values of email, and token in order to see if they return the right values, as a result the email cookie works, but the token cookie returns undefined.
<p dmx-text="cookies1.data.email+' '+cookies1.data.token">