I've had conversations with cyberpals and read CS forum threads about the "Remember me" Comment Form checkbox not working, and without a solution that I've seen. I knew it wasn't working on my blog, that's for sure. I was determined to get to the bottom of it during last night's geek session. It took longer than it should have, but I nailed the sucker.
The "Remember Me" checkbox remembers the name and blog address of anonymous (non-registered) users who add comments in Community Server. It's supposed to create a cookie that's read the next time the user visits the site so they don't have to re-enter their name and blog URL. It's simply common courtesy. But since "Remember me" wasn't working, everyone who visited my blog and was good enough to leave a comment had to type their name and URL on each visit.
When digging into the CommentForm.cs class I found that the cookie was being saved correctly, but the retrieved cookie was always null on return visits. Why was the retrieved cookie null? That was where I focused.
I should add here that the subject of cookies and authentication can be rather confusing in Community Server, only because Community Server supports so many different authentication methods: Windows (Active Directory), ASP.NET Forms, heck, even Passport authentication. Added to that you have shared authentication with other ASP.NET applications, the ASP.NET Membership Provider, shared authentication among multiple (virtual) CS Communities, sub-communities sharing authentication of a parent, and multi-server authentication to name a few. I'm still trying to get my head around this stuff. One thing I do know is that Cookies play a role in most of these schemes, particularly with shared authentication. I mention this because the Remember Me issue has NOTHING to do with any of those things. Remember Me is a separate cookie that saves and retrieves a name and a URL field on the Blog and Gallery Comment Form. And that's all it does.
So after confusing myself (and burning up precious latenight mental cycles) thinking the issue was something more complicated than it was, I focused in on the issue at hand and stumbled on the simple solution. I added an .Expires property when saving the cookie in the btnSubmit_Click() method of the CommentForm.cs class.
userCookie.Expires = DateTime.Now.AddYears(1);
That did it. You good folk who comment on this blog, I now welcome you back with full Remember Me functionality!
[tags: Community Server, CSComments]