none
Implement a session mechanism in an office 365 app

    Question

  • Is there a way to implement a session mechanism to be able to know if a user has already launched this app or not

    I tried to record something in the server Session variable but this doesn't seem to work (note : my app runs on an IIS server hosted in windows azure)

    Thank you

    Monday, July 08, 2013 2:57 PM

Answers

  • Hi Thibault,

    I suppose it depends on whether you want to track a particular computer versus a particular person(e.g., a single signed-in Live ID entity), and how resilient you want the method to be to things like clearing the cache.

    For tracking a particular computer (but again, susceptible to clearing of cache), you can use window.localStorage.  Plenty of examples out there on the internet.

    For tracking a particular person's usage of the app (and assuming the app is being pushed to the Office Store), you can use the Licensing mechanism (http://msdn.microsoft.com/en-us/library/jj163257.aspx) of apps for Office.  To do this, you would create a web service (http://blogs.msdn.com/b/officeapps/archive/2013/06/10/create-a-web-service-for-an-app-for-office-using-the-asp-net-web-api.aspx) that would accept the licensing token received by the app on initialization, and call the validation service (http://msdn.microsoft.com/en-us/library/jj163908.aspx).  From the validation service response you can get the "UserID".  With this information, and a database, you can easily check whether such person has launched your app before, how long it's been, whether they are a paid or free customer, and so forth.  You can get full-fledged statistics out of this as a bonus, if you want to track it.

    Hope this helps,

    - Michael


    Michael Zlatkovsky | Program Manager, Visual Studio Tools for Office & Apps for Office

    Wednesday, July 10, 2013 6:14 PM

All replies

  • Hi Thibault,

    Just to clarify:  do you mean for apps for Office or apps for SharePoint?  What scenario are you trying to accomplish?

    - Michael


    Michael Zlatkovsky | Program Manager, Visual Studio Tools for Office & Apps for Office

    Tuesday, July 09, 2013 6:50 PM
  • Hi,

    It's an app for Office the idea is quite simple : user A launches the app, close it and reopens it a week later, is there a way to recognize this user when he relaunches the app (as I could do with a standard browser) ?

    Does the "excel embeded browser" that launches the Task pane, uses cookie or something similar ?

    - Thibault

    Wednesday, July 10, 2013 4:47 PM
  • Hi Thibault,

    I suppose it depends on whether you want to track a particular computer versus a particular person(e.g., a single signed-in Live ID entity), and how resilient you want the method to be to things like clearing the cache.

    For tracking a particular computer (but again, susceptible to clearing of cache), you can use window.localStorage.  Plenty of examples out there on the internet.

    For tracking a particular person's usage of the app (and assuming the app is being pushed to the Office Store), you can use the Licensing mechanism (http://msdn.microsoft.com/en-us/library/jj163257.aspx) of apps for Office.  To do this, you would create a web service (http://blogs.msdn.com/b/officeapps/archive/2013/06/10/create-a-web-service-for-an-app-for-office-using-the-asp-net-web-api.aspx) that would accept the licensing token received by the app on initialization, and call the validation service (http://msdn.microsoft.com/en-us/library/jj163908.aspx).  From the validation service response you can get the "UserID".  With this information, and a database, you can easily check whether such person has launched your app before, how long it's been, whether they are a paid or free customer, and so forth.  You can get full-fledged statistics out of this as a bonus, if you want to track it.

    Hope this helps,

    - Michael


    Michael Zlatkovsky | Program Manager, Visual Studio Tools for Office & Apps for Office

    Wednesday, July 10, 2013 6:14 PM
  • Thank you exactly what I needed

    Thursday, July 11, 2013 8:55 AM
  • Based on the UserId is it possible to collect additionnal data ? Like user country for instance ?
    Thursday, July 11, 2013 9:09 AM
  • As far as information you can get from the validation service, see http://social.msdn.microsoft.com/Forums/office/en-US/7a5bf608-7f31-452b-a486-da47c1971c49/implement-a-session-mechanism-in-an-office-365-app.

    For getting information like user country, I suppose you might be able to use IP addresses and parse them according to a the country they belong to (much as you would tracking where your visitors come from on a regular website) -- but there isn't anything for this as part of the validation service, no.

    Hope this helps,

    - Michael


    Michael Zlatkovsky | Program Manager, Visual Studio Tools for Office & Apps for Office

    Thursday, July 11, 2013 5:33 PM