I have a javascript app running in a home page component. It calls into a web service, which in turn calls the salesforce API. I would like to use the API_Session_ID variable to save re-logging in. How do I expose this to the javascript running in my home page component? Ideally I would like to use apex to render a small piece of script, initialising a javascript variable with the API_Session_ID variable, onto all pages, but I can’t see how to do this.
Note – I can’t use VF as the app is running in a home page component. The normal solution for that (run as VF in an iframe) is not available to me as I need to access the javascript objects in the main page, which I can’t do from an iframe.
Ok so I figured this out. There’s a value ‘sid’ in the session cookie, and that’s what one needs with a bit of tweaking. Easy when you know how! Here’s the link:
http://forums.sforce.com/t5/forums/forumtopicprintpage/board-id/general_development/message-id/7209/print-single-message/false/page/1
It’s a bit out of date. I pass the cookie sid value, and window.location.host to my php web service. The php to make these values work is: