I am developing an e-Commerce site and I am using login control for users to login.
Once they login they can go to search page and search for products and go ahead with their purchase.
To make the payment I am using WorldPay. After the payment is completed, I want to redirect the users to
their purchased cart. But, the users are automatically logged out. They have to login again. I WANT TO KEEP THE USERS LOGIN DETAILS AND KEEP THEM LOGGED IN EVEN AFTER THE PURCHASE, UNTIL THEY CLICK ON Logout button.
I have given a web.config file inside Users folder, for extra securit and it has the following lines of code:-
Sometimes when I remove my web.config from my Users folder it is working.
But, I use this extra web.config for extra security.
How can I make the user keeps logged in even after the payment is completed
(when he is redirected from the WorldPay as well)?
Loading
r pPosted May 14, 2009, 9:54 AM
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Nipun TomarPosted May 14, 2009, 12:00 AM
First authenticate the user from database and then add a FormAuthentication ticket
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket
(1, // Ticket version
UserName, // Username associated with ticket
DateTime.Now, // Date/time issued
DateTime.Now.AddMinutes(30), // Date/time to expire
false, // "true" for a persistent user cookie
HttpContext.Current.Session["UserType"].ToString(), // User-data, in this case the roles
FormsAuthentication.FormsCookiePath);
// add cookies
string hash = FormsAuthentication.Encrypt(ticket);
HttpCookie cookie = new HttpCookie(
FormsAuthentication.FormsCookieName, // Name of auth cookie
hash); // Hashed ticket
// Set the cookie's expiration time to the tickets expiration time
if (ticket.IsPersistent) cookie.Expires = ticket.Expiration;
// Add the cookie to the list for outgoing response
HttpContext.Current.Response.Cookies.Add(cookie);
r pPosted May 13, 2009, 10:00 AM
Nipun TomarPosted May 12, 2009, 3:15 AM