How to maintain salesforce session id in visualforce page?

2.3k Views Asked by At

i had written a javascript in home page component.it'll load as soon as we login to the salsforce and its working fine. but if i open Visualforce page it throws "sf:invalid code...invalid session id." How to resolve this issue. following is the session code i used in javascript.

sforce.sessionId = getCookie('sid'); sforce.connection.sessionId=sforce.sessionId;

1

There are 1 best solutions below

0
On BEST ANSWER

If you want get session id, you can try to use next JS code:

var __sfdcSessionId = '{!GETSESSIONID()}';