I need to know the visitor's first visit to a page after every new login into SharePoint.

Is there a way for me to get a "SessionId" or any session-unique variable in SharePoint online using javascript, where the variable will change or reset on every current user login?

I notice that a secured cookie name, FedAuth has a session-unique value but you cannot retrieve the value with javascript alone in many browsers.

1 Answer 1


There is nothing OOB (on the client side) that can help you to know if it is the first time (or not) that the user is entering your site. But, with JSOM you can easily create a list of users and add a user there everytime he enters the site. This way the next time he does, if he already exists on the list it means that its not his first time.

This can be useful because you can do it even per Site or Site-Collection. You choose your own logic.

Hope it helped.

  • Thank you for the idea @Tiago Duarte, but the list you mentioned will not be cleared when the user logs out, thus, when the user signs in back, the user's username is still in the list you mentioned. It has to be his first time to the page on his every new login (question edited to be clearer) Commented Oct 14, 2016 at 21:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.