Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / April 2008

Tip: Looking for answers? Try searching our database.

Forms Authentication non-persistent cookie not expiring after closing     the browser

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rh.krish@gmail.com - 09 Apr 2008 06:24 GMT
I have a typical ASP.NET 2.0 Forms authentication application which
authenticates against Active Directory. I use non-persistent cookie so
that the user is NOT remembered across browser sessions. The timeout
is set to 10 minutes. Here is the important code snippets that I took
from my original code:

string roleToCheck = .....;
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1,
member.UserName, DateTime.Now, DateTime.Now.AddMinutes(10), false,
roleToCheck, FormsAuthentication.FormsCookiePath);
               string encryptedTicket =
FormsAuthentication.Encrypt(ticket);
               HttpCookie authSessionCookie = new
HttpCookie(FormsAuthentication.FormsCookieName, encryptedTicket);
               authSessionCookie.HttpOnly = true;
authSessionCookie.Expires = ticket.Expiration;
               Response.Cookies.Add(authSessionCookie);
FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, false);

Note that I'm setting the 2nd parameter to false which means that it
creates non-persistent cookie. Now I opened the IE browser and logged
in by entering the user credentials. I closed the window and there was
no other instance of IE running. I opened another IE and entered the
URL and it straight away went to default page instead of Login page.

1. Why is the cookie not expiring even after I close the browser?
2. If that's how the ASP.NET works, is there any work around so that
whenever the user closes IE and opens another IE, he should be forced
to login once again?

Thanks,
Hari.
Matthijs Krempel - 09 Apr 2008 09:25 GMT
Hari,

If you authenticate against the Active Directory, why not host your solution
under intergrated security?

That would solve a lot of your problems.

Kind regards,

Matthijs Krempel

> I have a typical ASP.NET 2.0 Forms authentication application which
> authenticates against Active Directory. I use non-persistent cookie so
[quoted text clipped - 28 lines]
> Thanks,
> Hari.
rh.krish@gmail.com - 09 Apr 2008 17:14 GMT
Hi Matthijs - The reason that we are not using Integrated Security and
using Forms is because we have some external (limited) users who
access the application out of our network.

-Hari.

On Apr 9, 1:25 am, "Matthijs Krempel" <matthijs.krem...@hotmail.com>
wrote:
> Hari,
>
[quoted text clipped - 6 lines]
>
> Matthijs Krempel
Matthijs Krempel - 10 Apr 2008 08:41 GMT
Hi Hari,

You can write a custom membershipprovider, that uses both your custom
authentication scenario and uses the activedirectorymembershipprovider.

Forms authentication will do the rest for you, no mucking about with writing
custom authentication logic.

With kind regards,

Matthijs Krempel

> Hi Matthijs - The reason that we are not using Integrated Security and
> using Forms is because we have some external (limited) users who
[quoted text clipped - 15 lines]
>>
>> Matthijs Krempel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.