468,115 Members | 2,078 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,115 developers. It's quick & easy.

AccessMembershipProvider and persistent tickets

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.
Oct 19 '08 #1
1 1254
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.U serName,
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.U serName,
Login1.RememberMeSet);
}
else
{
Login1.FailureText = "Invalid user.";
}

Regards.
Oct 21 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Randell D. | last post: by
16 posts views Thread by Paul Rubin | last post: by
4 posts views Thread by M?rio Amado Alves | last post: by
1 post views Thread by Eric Lindsay | last post: by
reply views Thread by Niebs | last post: by
3 posts views Thread by sanchita | last post: by
5 posts views Thread by didacticone | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.