Forms Authentication

B

Bruce

Can anyone suggest an example of Forms Authentication?

I'm receiving the following error when trying to run a load test program.

"Cannot set cookies from header server because name-value pair contains
invalid characters"

This the code I'm using to the cookie, but as far I can tell, this should
work.

// Create a new ticket used for authentication
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, // Ticket version
(string)Session["g_Member_Id_Name"], // Member name to be associated
with this ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes((int)Session["g_Add_Minutes_Num"]), //
Date/time to expire
false, // "true" for a persistent user cookie (could be a checkbox on
form)
(string)Session["g_Member_Type_Name"]); // Member-data (the roles from
this user record in our database)

// Hash the cookie for transport over the wire
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie (it's the
name specified in web.config)
hash); // Hashed ticket

// Add the cookie to the list for outbound response
Response.Cookies.Add(cookie);

Any thoughts appreciated!

Thanks
 

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
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top