WordPress.org

Ready to get started?Download WordPress

Forums

Password Protected
Cookie and Session time? (5 posts)

  1. iqadmin
    Member
    Posted 7 months 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 7 months 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 7 months 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 7 months 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 7 months 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!

Reply

You must log in to post.

About this Plugin

About this Topic