Forms authentication

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.
 
M

Mark MacRae

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());
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,678
Members
48,796
Latest member
Greg L.

Latest Threads

Top