Increase 'Remember Me' to 2 weeks

Hi all,

I am trying to implement this snippet of JS from the Knack site to increase the ‘Remember Me’ time to 2 weeks
https://docs.knack.com/docs/utilize-remember-me-option

When I add it it stops the previous sections from working (these change the logo on when saved to the homescreen of mobile devices). I expect it is something fairly simple and obvious - any suggestions welcome…

Many thanks

/* Change the favicon to an image saved on the database. */
ChangeFavicon();

function ChangeFavicon() {
var link = document.querySelector(“link[rel*=‘icon’]”) || document.createElement(‘link’);
link.type = ‘image/x-icon’;
link.rel = ‘shortcut icon’;
link.href = ‘https://api.knack.com/v1/applications/611d1c7fdc6694001f1cdc2d/download/asset/61bf4efc6dd776001ee48314/5only.png’; //path to your icon
document.getElementsByTagName(‘head’)[0].appendChild(link);
}

/* Change the below icons to your personalized icon links. */
$(“head”).append("");
$(“head”).append("");
$(“head”).append("");
$(“head”).append("");

/* Change the ‘Remember Me’ to 2 weeks from 48 hrs. */
curl -H “Content-Type: application/json”
–data ‘{“email”:“email address”,“password”:“password”,“remember”:true}’
https://api.knack.com/v1/applications/611d1c7fdc6694001f1cdc2d/session

Good morning @Hugo

The curl command won’t work in JavaScript. Instead you want to use an ajax request. Here is an example of an ajax request:

// change "scene_1" to the scene you want to listen for
$(document).on('knack-scene-render.scene_1', function(event, scene) {
  // change scene_1 and view_1 to the view that works with the logged-in user
  $.ajax({
    url: 'https://api.knack.com/v1/pages/scene_1/views/view_1/records',
    type: 'GET',
    headers: {
      'Authorization': Knack.getUserToken(),
      'X-Knack-Application-Id': Knack.application_id,
      'Content-Type': 'application/json'
    },
    success: function(data) {
      alert('Got records!')
      console.log(data);
    }
  });
});

The above code would need to be updated to fit your purposes.

However hopefully that helps get you in the right direction.

Thanks for that, I’ll give it a go and see how I get on.

Cheers

@Hugo By the way I meant to ask you—Are your users logging in remotely or through the app as usual? If your users are logging in through the app then Remember Me is already 2 weeks. The documentation you shared is only necessary for remotely logged-in users. In your case it’s probably unnecessary. Cheers

Hi,

through the app as usual. It is strange, I am sure it is logging me out (on my iPhone almost daily - I’ll make a point of checking this to be sure. It is on mobile devices I am trying to extend the duration for, not PCs - apologies if that wasn’t clear previously.

Thanks

On mobile the 2 week rule is not enforced, it seems to logout daily.