Need to add a terms of agreement page on the SP online site, where each user have to agree to the terms of use, until they do so we need to lock the site for them and show them policy page.

The problem is, if some people have documents from the site bookmarked from the site, they can access those documents. How to block that access until the user accessing that document hasn't accepted the terms of use for the site

  • Did you implement it via AZureAD terms of user with Conditional access? what is the expiry date you set to start with.
    – Waqas Sarwar MVP
    Jan 9, 2020 at 18:23
  • Can we use that for a particular SharePoint Online site ?
    – RHM
    Jan 9, 2020 at 18:53
  • did you follow this "docs.microsoft.com/en-us/azure/active-directory/…" to implement the terms of use. if you properly configured then next sign in required this
    – Waqas Sarwar MVP
    Jan 9, 2020 at 18:56

1 Answer 1


You can implement the SetCookie function in your page.

function SetCookie (name, value) {
         var argv = SetCookie.arguments;
         var argc = SetCookie.arguments.length;
         var expires = (argc > 2) ? argv[2] : null;
         var path = (argc > 3) ? argv[3] : null;
         var domain = (argc > 4) ? argv[4] : null;
         var secure = (argc > 5) ? argv[5] : false;
         document.cookie = name + "=" + escape (value) +
         ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
         ((path == null) ? "" : ("; path=" + path)) +
         ((domain == null) ? "" : ("; domain=" + domain)) +
         ((secure == true) ? "; secure" : "");

function setC(form) {
   var expdate = new Date ();
   expdate.setTime (expdate.getTime() + (24 * 60 * 60 * 1000 * 31));
   SetCookie (form.name, form.value, expdate);

Similar question is answered here:

Looking to create a “Terms and Conditions” page for our Company's Sharepoint Intranet

For Cookie java script details, please refer this.

Another approach for the same from this thread create agreement page in SharePoint site:

To do it right, you would probably best go with an FBA kind of approach. Your custom membership provider could determine whether the user has accepted before and then take the right action.

A second best approach (or at least another approach) would be to insert some jQuery into a common master page that performs this check. The drawback, of course, is that it will be running all the time someone hits a page.

I can think of other more fancy approaches. You could have a custom asp page that goes and provisions their account after they accept. That would relatively complicated.

  • How can we stop users access to the documents link which are stored previously as a bookmark in the browsers ? those links still tend to open up
    – RHM
    Jan 9, 2020 at 18:04

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.