Solved single sign on

Posted on 2011-04-20
Last Modified: 2012-06-22
I am trying to have a single sign on work between different domains (i.e. and

What I have tried to do so far is this.

On, I have a hidden iframe.  Once I log in and am forms authenticated on, I execute this line of code to "auto login" on (of course I would encrypt all data passed back and forth):

hologinframe.Attributes["src"] = "http:/";

The autologin.aspx page does this on pageload:

   FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(1, "username", DateTime.Now, DateTime.Now.AddMinutes(60), true, "");

        // Get the encrypted version of the ticket
        string strEncrypted = FormsAuthentication.Encrypt(ticket);

        // Put it into a cookie
        HttpCookie hc = new HttpCookie(FormsAuthentication.FormsCookieName, strEncrypted);
        hc.Expires = DateTime.Now.AddHours(12);

        Response.Cookies.Add(hc); // Add it to the cookies collection                                                      

        Response.Redirect(FormsAuthentication.GetRedirectUrl("username", true));

The odd thing that I am finding is that this works on IE, but does not on FF or Chrome.

The only way I could get the autologin to the site working on FF or Chrome is if I set the frame.src in the pageload of the login page of instead of the login_LoggedIn function.

Any help to get this working on in all browsers in the login_LoggedIn function?
Question by:MikeCausi
    LVL 18

    Expert Comment

    by:Gary Davis
    Verify your cookies are not being blocked - they may be consicered 3rd-party and depending on browser privacy settings, may be blocked. Use Firebug to view the Http net traffic and cookies sent by the browser.

    Usually it is IE that is the problem but apparently not in this case.

    Gary Davis

    Author Comment

    Doesn't seem to be blocking the cookies.

    I did test something different, however.  Instead of trying to access the logged_in event of the login control, I tried a regular button click on the website to auto login to the site.  This time it worked.  Something about the login control events is not letting the setting of the frame src work.
    This doesn't yet resolve my problem since I want to use the built in login control.
    LVL 1

    Accepted Solution

    I think FF and Chrome block cookies which are made inside an (invisible) iframe. The element needs to be visible for the cookie to be created. What we did is that the page on the second host generates an image (this just can be a 1x1pixel image). If you show that somewhere on the page the cookies should be created.

    Author Closing Comment

    Going to come back to this another time, but your solution seems reasonable.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Introduction (All good things must come to an end ( The original MySQL API ( has gone away, deprecated by PHP in Version 5.5, and removed from PHP in all curre…
    If I have to fix slow responding website my first thoughts are server side optimizations: the database may not be optimized or caching is not enabled, or things like that. We often overlook another major part of our web application: the client. We o…
    Use Wufoo, an online form creation tool, to make powerful forms. Learn how to selectively show certain fields based on user input using rules to gather relevant information and data from your forms. The rules feature provides you with an opportunity…
    Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now