AccessMembershipProvider and persistent tickets


J

Jason James

Hi,

I am exploring the possibility of using the MSAccess provider for
membership, etc. All is working well, including being able to use it
for webparts, user authentication, etc. I can create users, change
passwords, request the password (I am currently using "Clear" as the
password format, and when I drop the LoginStatus control onto the form
it shows the correct status However, I am struggling with the login
control and the use of the Remeber Me Next Time check box.

The login works fine and using the following code:

protected void Page_Load(object sender, EventArgs e)
{
Response.Write("Hello, " +
Server.HtmlEncode(User.Identity.Name));
try
{
FormsIdentity id = (FormsIdentity)User.Identity;
FormsAuthenticationTicket ticket = id.Ticket;
Response.Write("<p/>TicketName: " + ticket.Name);
Response.Write("<br/>Cookie Path: " + ticket.CookiePath);
Response.Write("<br/>Ticket Expiration: " +
ticket.Expiration.ToString());
Response.Write("<br/>Expired: " +
ticket.Expired.ToString());
Response.Write("<br/>Persistent: " +
ticket.IsPersistent.ToString());
Response.Write("<br/>IssueDate: " +
ticket.IssueDate.ToString());
Response.Write("<br/>UserData: " + ticket.UserData);
Response.Write("<br/>Version: " +
ticket.Version.ToString());
}
catch (Exception ex)
{
Response.Write(ex.Message);
}
}

yeilds the following details:

Hello, JohnDoe
TicketName: JohnDoe
Cookie Path: /
Ticket Expiration: 30/11/2008 13:31:37
Expired: False
Persistent: False
IssueDate: 19/10/2008 21:31:37
UserData:
Version: 2

The persistance is set to false, but I see no way of setting it to
true. The forms section of my web.config file is as follows:

<authentication mode="Forms">
<forms loginUrl="Login.aspx"
defaultUrl="Login.aspx"
protection="All"
timeout="60000"
name=".AccessPortal"
slidingExpiration="true"
cookieless="UseCookies"
enableCrossAppRedirects="false"
path="/" />
</authentication>

Does anyone have any thoughts on how I can set persistence to true and
have the cookie retained to enable me not to have to login the next
time I visit the site?

Many thanks in advance,

Jason.
 
Ad

Advertisements

J

Jason James

Guys,

found the problem and it was a stupid one.

I had set the persistent flag in the RedirectFromLoginPage to false as
below:

if (Membership.ValidateUser(Login1.UserName, Login1.Password))
{
FormsAuthentication.RedirectFromLoginPage(Login1.UserName,
false);
}
else
{
Login1.FailureText = "Invalid user.";
}


and not to the value indicated by the state of the "Remeber Me" check
box on the form as below:

if (Membership.ValidateUser(Login1.UserName, Login1.Password))
{
FormsAuthentication.RedirectFromLoginPage(Login1.UserName,
Login1.RememberMeSet);
}
else
{
Login1.FailureText = "Invalid user.";
}

Regards.
 

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

Top