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 / July 2005

Tip: Looking for answers? Try searching our database.

Authorization cookie not valid for subdomains ?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
craigkenisston@hotmail.com - 18 Jul 2005 03:02 GMT
Hi,

I create a one day ticket in my authentication code like this :

private void btnLogin_Click(object sender, System.EventArgs e)
{

string _userId = txtUserId.Text;
string _password = txtPassword.Text;

if (FormsAuthentication.Authenticate(_userId,_password))
{
    FormsAuthentication.RedirectFromLoginPage(_userId,false);
    FormsAuthenticationTicket authTkt = new FormsAuthenticationTicket(1,
"mycookie", DateTime.Now, DateTime.Now.AddDays(1), true, _userId);
    HttpCookie authCookie = new
HttpCookie(FormsAuthentication.FormsCookieName);
    authCookie.Value = FormsAuthentication.Encrypt(authTkt);
    authCookie.Expires = DateTime.Now.AddDays(1);
    Response.Cookies.Add(authCookie);
}

}

Recently I added some subdomains to my site and I realize that the
authorization is not valid there, i.e. the user appears as not logged
in.
How can I make an authorization ticket valid for all the domain and its
subdomains ?
RCS - 18 Jul 2005 03:19 GMT
     authCookie.Domain = "mydomain.com";

That will make the cookie valid for any subdomain within mydomain.com

To be safe, you may want to do:

     authCookie.Path = "/";

too - that makes the cookie valid for any directory within the site too...

HTH

> Hi,
>
[quoted text clipped - 25 lines]
> How can I make an authorization ticket valid for all the domain and its
> subdomains ?
craigkenisston@hotmail.com - 27 Jul 2005 07:03 GMT
Thanks, that worked!

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.