Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Easy way to retrieve sessionToken

Hello!
I've tried to find out how to get the sessionToken when im in a new page.

This is what I mean:
I have two pages: Login and Menu.

Everything works perfect when I click "Log in!" button. After mapping the username and password, I navigate to a page (menu). (Mapping = Order 1, navigate = Order 2).
What now?
Do I have to Set the sessionToken in a storage variable? Or is it possible to retrieve the sessionToken in another way?

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Easy way to retrieve sessionToken

On the success event of the login the service responds with the session token. Grabbing it then and placing it in local storage is the best method that I have found. In fact, it is the only method I know of.

So after you map the user info into a user storage variable (I am assuming mapping if from the inputs on the page), map the session token into a storage variable. Do this session token mapping the the success event of the login service.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Easy way to retrieve sessionToken

Hello Nicklas,

The best way is using storage variables for that. Please clarify, what exactly doen't fit you in that case?

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Easy way to retrieve sessionToken

Thank you for answeres!

If we do an example:

After success login, I put the sessionToken in a storage variable.

Lets say I want the sessionToken be shown in a label on the next page (in this case "menu").
How do I do that?

Jack Bua
Posts: 0
Joined: Sun Jun 28, 2015 10:16 pm

Easy way to retrieve sessionToken

Assuming that you want it to go into the label when the page shows:
1 in the events section of the platform, select your page, select the page show event, select the action of mapping
2 check the box for storage on the right and expand the page components on the left until you find your label.
3 click and drag the session storage variable over to the Text property of the label.
4 save and test.

BONUS:

The console is your best friend when it comes to testing.

https://devcenter.appery.io/documenta...

If you would like, after step 3, do this:
click the green icon that says "JS" in it. Now you can add JS to this mapping. type

console. log("Session Token is: " + value); // This adds the session token and some text to the console

return value; //this assigns the value of the storage variable to the mapping destination.

Now, when you get to that page, you can open your console and see your session token. I log the session token to the console on every successful login so that I can grab a fresh token every time I need one when trying something in a service test.

Nicklas
Posts: 0
Joined: Thu Jul 03, 2014 8:51 am

Easy way to retrieve sessionToken

Thank you! I found it out with your help!:)

Return to “Issues”