I have a PHP webpage and I want to pass my session to my XBAP app.

I created a cookie.

$opts = array('http' => array('header'=> 'Cookie: ' . $_SESSION['FILENAME']."\r\n"));
                            $context = stream_context_create($opts);
                            $contents = file_get_contents("http://localhost/WpfBrowserApplicationUltimate.xbap", false, $context);
                            echo $contents;

  private void btnAbout_Click(object sender, RoutedEventArgs e)
            //MessageBox.Show("RichTextPad. © 2014  University.", "About RichTextPad", MessageBoxButton.OK, MessageBoxImage.Information);
                String cookie = Application.GetCookie(BrowserInteropHelper.Source);
            catch (Win32Exception)

But the magic doesn't happen.

Can someone clarify what am I doing wrong?


Are you using the built in WebBrowser control?

Yes, I am.

Nonetheless, I deployed the XBAP app on my Apache server.

I'm guessing that the exception doesn't throw either?

Have you tried including only the domain that got set rather than the full URI? It may get confused if you give it a file name.

If you're using the WebBrowserControl you should be able to retrieve the cookie directly from the control.
If you're using HttpWebRequest (with a cookiecontainer) you should be able to get it from the container.

It automatically catches the exception as "No more data is avaliable".

I tried including only the domain, did not work as well.

Using HttpWebRequest was my initial thought but it's not passing it to the app...

HttpWebRequest is probably what you want in my opinion, there are some modifications you have to make to it in order for it to work properly. This primarily being the addition of a "CookieContainer"

I will add this as a code snippet for DW. I'll come back and update this thread when I'm done.

EDIT: Code Snippet can be found Here :)

Well, thank you very much for the Snippet. I just changed the domain name and I dunno if I should be adjusting anything else. Is it automatically catching the cookies, or should I do anything else to use the method in i.e. a button? Once a button is clicked, it would display the content of the cookies.

So long as the cookies are set it will pass them back and forth automatically. You should be able to pick them up on your website.