Search code examples
c#cookiesawesomium

How to stay logged in for Awesomium?


I want to program an app with C# and Awesomium for remembering that a user is logged into the site. For this I use the following code:

private void button1_Click(object sender, EventArgs e)
{

    Uri link = new Uri("http://www.mywebsite.com");
    webControl1.Source = link;
     string Values="";
     WebSession session = WebCore.CreateWebSession("d:\\temp", WebPreferences.Default);
    session.SetCookie(link, Values, true, true);

}

But when I close and run the app again, I must log in again. How can I do this?


Solution

  • Looks like you're setting the last parameter to true in your call to the SetCookie function - This means you're setting a session cookie not a persistent cookie that will be saved to disk

     private void button1_Click(object sender, EventArgs e)
     {
    
         Uri link = new Uri("http://www.mywebsite.com");
         webControl1.Source = link;
         string Values="";
         WebSession session = WebCore.CreateWebSession("d:\\temp", WebPreferences.Default);
         session.SetCookie(link, Values, true, **false**);
    
    }
    

    Reference: See here