Password protected pages setTimeout and password for entire site?

Hi, I am looking to created a password protected page in Webflow and wanted to know the following:

  1. If a user logs into a password-protected page. Would I be able to manage when they would need to enter a password again? So setting a timeout
  2. Is it possible to have a password protect site (the entire site, not just a page)?

Currently running into the same issue - please advise @webflow!

1 Like

Hi, I’m also interested in setting a timeout or knowing how long exactly viewers of my password-protected pages have access to those pages AFTER I’ve changed the password in webflow. Thanks

I got these snippets from chatGPT. Lmk if any of them work:

Timeout user if there is no input from mouse or keyboard
<script>
// Set the timeout duration in milliseconds
const timeoutDuration = 600000; // 10 minutes

// Store the last time the user interacted with the site
let lastInteractionTime = Date.now();

// Check the interaction time periodically
setInterval(() => {
  const currentTime = Date.now();

  // If the timeout duration has passed, redirect to the login page and log out the user
  if (currentTime - lastInteractionTime >= timeoutDuration) {
    redirectToLogin();
  }
}, 1000);

// Listen for user interactions and update the last interaction time
document.addEventListener('mousemove', updateInteractionTime);
document.addEventListener('mousedown', updateInteractionTime);
document.addEventListener('keypress', updateInteractionTime);

// Redirect to the login page and log out the user
function redirectToLogin() {
  Webflow.Membership.logout();
  window.location.href = '/log-in';
}

// Update the last interaction time
function updateInteractionTime() {
  lastInteractionTime = Date.now();
}
</script>

Timeout user regardless of input from mouse or keyboard
<script>
// Set the timeout duration in milliseconds
const timeoutDuration = 600000; // 10 minutes

// Store the last time the user interacted with the site
let lastInteractionTime = Date.now();

// Check the interaction time periodically
setInterval(() => {
  const currentTime = Date.now();

  // If the timeout duration has passed, redirect to the login page and log out the user
  if (currentTime - lastInteractionTime >= timeoutDuration) {
    redirectToLogin();
  }
}, 1000);

// Redirect to the login page and log out the user
function redirectToLogin() {
  Webflow.Membership.logout();
  window.location.href = '/log-in';
}

// Update the last interaction time
function updateInteractionTime() {
  lastInteractionTime = Date.now();
}
</script>