Password protection – work around for collection pages

The client’s asked me to password protect a small section of a site, but that’s to include a staff news blog. So, now I’m stuck since password protection isn’t available for dynamic pages.

I’d like to pick your brains: Is there any work-around at all adding Custom Code to the collection page template?

It seems that WF places a cookie named ‘wf_auth_page’

I was thinking like so:

  1. Javascript to check whether wf_auth_page cookie exists
  2. If yes, do nothing
  3. If no, re-direct to URL (landing page of protected section, which would bing up the password page)

I would use or robots.txt to prevent search engines listing it – and perhaps interactions to prevent content showing up before the cookie check has taken place.

Perhaps all not perfect, but this would seem like a reasonable work-around to me. Trouble is that I can’t do Javascript, so would be hoping for some help here (and maybe this then also helps others).

Thank you!

Very basic password protection:

<script>
var password = "letmein";
if(prompt("Enter password:", "") !== password) window.location = "/";
</script>

Paste this in Page Settings > Header Code.

1 Like

Thank you for your reply @samliew. But this isn’t what I was asking about. I need to protect a collection page AS PART OF other static pages that are protected – i.e. no new/different password to be entered, but the collection pages should be visible to those who have are logged on with all others to be re-directed.

In that case, please vote for this wishlist item Page password protection for collection items (CMS) | Webflow Wishlist

There is no workaround as this is implemented server-side.

I would but I haven’t got any votes left.

Demo: Client-side Page-level Simple Password Protection

Password: letmein

1 Like

Thank you for the code.
I only counter one problem. If the time taking too long, the page will jump to home page.

thank you so much, i know it wasn’t what the guy that asked for it was, but it was exactly what i needed. Thanks!

This is now a Webflow feature!