Forms authentication

  • Thread starter Thread starter Ian Walsh
  • Start date Start date
I

Ian Walsh

I'm using forms authentication within a C# project.

I am using the standard code where a user attempts to access a page
when they are not logged into the system.

I am collecting a username / password and comparing this against a
SQLServer to authenticate the user. This all works fine if the user
already exist.

I also have a create account area that is not secured on my site. I
want to create a user and create the cookie so that the user is logged
on automatically after account creation. At present I create a user
and then the user needs to authenticate themselves using the login
page.

Any help appreciated.

Thanks.
 
Just set the cookie expiry to whatever you want when you create the ticket.
For example, if you want to remember their login for a month:

DateTime expirationTime;
expirationTime = DateTime.Now.AddMonths(1);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
sLoginName,
DateTime.Now,
expirationTime,
bRememberLogin,
sbRoles.ToString());
 
Back
Top