WordPress.org

Forums

Password Protected
Cookie and Session time? (5 posts)

  1. iqadmin
    Member
    Posted 2 years ago #

    I am looking to change the length of time that the plugin stores the cookie and session. For example, some plugins will create a cookie that gets reset (destroyed) after 2 weeks. The same plugin might reset the cookie if the user's session is closed.

    My question is: where in the code does it say the length of time that these cookies are stored for?

    My goal is have the cookie in place for a preset amount of time regardless of whether the computer or browser has shut down.

    As another question, does anyone know of a good method that would force a browser (and possibly the computer) to remember the cookie regardless of whether or not the browser or computer was shut down?

    http://wordpress.org/plugins/password-protected/

  2. Ben Huson
    Member
    Plugin Author

    Posted 2 years ago #

    You can use the 'password_protected_auth_cookie_expiration' filter to return a length of time for the cookie to last.

    https://github.com/benhuson/password-protected/blob/master/password-protected.php#L295

  3. iqadmin
    Member
    Posted 2 years ago #

    Hello Ben,

    Thank you for your rapid response!

    I just have a quick follow-up question. Does the cookie depend on the existence of the user's session? For example, if the user accidentally closes all of their browsers or if they restarted their computer, will the cookie still be active?

    Thank you very much for your help!

  4. Ben Huson
    Member
    Plugin Author

    Posted 2 years ago #

    Currently the cookie only lasts for the current session until a user quits their browser. I could add in another filter to set a longer expiration for the cookie itself to persist across sessions if that is helpful?

  5. iqadmin
    Member
    Posted 2 years ago #

    Yes, that would be great if you can do add a filter to have the cookie persist across sessions! Or you can show me how I can do that.

    Thank you!

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Password Protected
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic