views:

13

answers:

0

I have a C# custom application that obtains a cookie using OpenID in the following way::

using System;
using System.Windows.Forms;

namespace MyNamespace
{
    public class SignIn : Form
    {
        private WebBrowser _browser;

        public SignIn()
        {
            InitializeComponent();
        }

        private void SignIn_Load(object sender, EventArgs e)
        {
            string url = String.Format("http://{0}/appsignin.html",Globals.Instance.BaseUrl);
            _browser.Navigate(url);
        }

        private void browser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
        {
            HtmlDocument myDoc2 = _browser.Document;
            if (myDoc2 != null)
            {
                HtmlElement items = myDoc2.GetElementById("cookie");
                if (items != null)
                {
                    string cookie = items.GetAttribute("cookie");
                    Globals.Instance.Cookie = cookie;
                    Close();
                }
            }
        }

        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this._browser = new System.Windows.Forms.WebBrowser();
            this.SuspendLayout();
            // 
            // _browser
            // 
            this._browser.Location = new System.Drawing.Point(12, 12);
            this._browser.MinimumSize = new System.Drawing.Size(450, 260);
            this._browser.Name = "_browser";
            this._browser.ScrollBarsEnabled = false;
            this._browser.Size = new System.Drawing.Size(450, 260);
            this._browser.TabIndex = 0;
            this._browser.DocumentCompleted += new System.Windows.Forms.WebBrowserDocumentCompletedEventHandler(this.browser_DocumentCompleted);
            // 
            // SignIn
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.ClientSize = new System.Drawing.Size(474, 286);
            this.Controls.Add(this._browser);
            this.Name = "SignIn";
            this.Text = "3PointData Sign-In";
            this.Load += new System.EventHandler(this.SignIn_Load);
            this.ResumeLayout(false);

        }

        #endregion

    }
}

I can also obtain a cookie through the same mechanism (opening appsignin.html) in a browser. In that case, the browser stores the cookie (somewhere).

So my question is whether the user logs in via any of the four browsers, or one of my custom apps, can the cookie somehow be forwarded to the other apps and other browsers so that people don't have to log in twice? I can handle the case between my apps, so the question is really more about how cookies are stored by each browser, can a cookie be injected into a browser without logging in?

What's the right approach? Do I have to create add-ins for each browser? Any ideas at all would be helpful. Thanks!