Question

I am trying to get the remember me function to work in starter site in WebMatrix. From what I can see I need to set up a persistCookie put I cannot find code for WebMatrix. If anyone knows how to set this up or another way to get the remember me checkbox to work that would be awesome.

Was it helpful?

Solution

By default, the cookie is persisted for 30 minutes. If you want to persist it for longer periods, you need to add a section to the system.web node of your web.config:

<authentication mode="Forms">
    <forms timeout="10080"/> <!--one week-->
</authentication>

The timeout value is measured in minutes, so the example above will persist the cookie for 7 days.

Shared hosting providers often recycle the application pool every 20 minutes or so. If the keys for validation and encryption are configured in the machine.config to auto-generate (the default), any existing cookies will no longer work as the encryption will have changed. That will result in the user having to log in again. To prevent this happening, you can generate your own keys in your web.config file thereby opting out of auto-generation at runtime.

There are online tools that generate keys, but you can also use IIS to generate keys for you: http://blogs.msdn.com/b/vijaysk/archive/2009/05/13/iis-7-tip-10-you-can-generate-machine-keys-from-the-iis-manager.aspx

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top