1

I can spawn a browser from my Java thick client using java.awt.Desktop.

Apprarently, I can also spawn a browser from my .NET client using System.Diagnostics.Process.Start

My question is, is there a way in both Java / .NET to set a cookie when spawning the browser process? It doesn't look like there is - possibly due to security concerns?

toolkit
  • 49,809
  • 17
  • 109
  • 135

2 Answers2

1

There is not. You could probably add some sort of plugin in the target browser, but that would be with a different mechanism.

What java.awt.Desktop does , it just launch the browser. There is no more interaction with it.

OscarRyz
  • 196,001
  • 113
  • 385
  • 569
1

What I ended up doing was to spawn an intermediate page like:

Desktop.getDesktop().browse(
    new URI("http://localhost/intermediate.html?mytoken=bar")
);

Then have a bit of JavaScript to take the request param, set it as a cookie, and then forward onto the destination page.

var query = location.search;
var tokenRe = /mytoken=([^?]*)/;
var token = query.match(tokenRe)[1];
document.cookie = 'MYTOKEN=' + token
location.replace('http://localhost/destination')

Simples!

toolkit
  • 49,809
  • 17
  • 109
  • 135