Stop user logging out automatically


I used pauli:accounts-linkedin package to sign in users. If a new tab is opened or page is refreshed or server is restarted , user gets signed out. How to fix this and keep user logged in even when browser is closed and reopened?
Thanks in advance for help.


Assuming you have a app/imports/startup/server or something similar for your folder structure, you can use this. Just stick it in server, and add the hook to your app/imports/startup/server/index.js

So: imports/startup/server/accounts.js

import { Accounts } from 'meteor/accounts-base';

  // loginExpirationInDays: 0.0416667,
  loginExpirationInDays: 3650,

And: imports/startup/server/index.js (as an example)

import './accounts.js';  // this is what you care about
import './accounts/email-templates';
import './browser-policy';
import './fixtures';
import './api';

Edit: I use for dev, so expiry set to 10 years. Please think about what you are doing if in production.

1 Like

thanks a lot for your reply. Honestly I din’t expect such a fast reply!

I did the same as you wrote but nope… still same problem. Additionally I tried to change the service configuration by placing it inside and outside of Meteor.startup() block. Finally moved it to a different js file and imported it. Then it worked couple of times and then again, same issue. If a new tab is opened, user is logged out from all tabs.

Update: loginExpirationInDays wasn’t needed actually it was my idiotic fault in calling logout function (didn’t bind it to button).

1 Like