I'm have a java program that uses Apache httpclient api. This is used to login to and communicate to a webapp. Once logged in, there's a situation in which the program issues an execute process to open up firefox to hit the webapp and allow the user to see data in the browser. Since the java program is already logged in, is there a way to share that current session PHPSESSID so that the spawned firefox is already logged in and working in that same session?
A:
You could write your own session handling callback functions that will store session data in a database. Then all you need to do is pass the PHPSESSID along with the URL that you're opening in Firefox and you can continue the session from there. Read more here:
http://www.php.net/manual/en/function.session-set-save-handler.php
There are some good examples of a databased session in the user comments
thetaiko
2010-02-10 15:30:47
Guess I should have mentioned, I cannot make changes to the PHP webapp. I get the PHPSESSID upon login, is there a way to pass that as a parameter in the URL to the firefox command-line spawn process?
Nick
2010-02-10 15:37:39
You could simply concatenate the PHPSESSID onto the URL you're opening as a query (http://urltoopen.com/?session=PHPSESSID...) but unless the webapp knows what to do with that its not going to be very useful. Session information is typically stored in cookies on the client side and cookies are browser specific. Perhaps its possible to save the PHPSESSID cookie in Firefox's cookie directory? Then when Firefox opens it will use that cookie? Just a thought - never tried it and don't know if it will work
thetaiko
2010-02-10 16:03:44
Slight modification - it looks like firefox stores cookies in a cookies.sqlite database - save the cookie in there.
thetaiko
2010-02-10 16:06:49