function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
evgenykaevgenyka 

Login using active_session

Hello
Right now i connecting to SF from php using master username and password.

Let's say i would like to call index.php and pass to it SF session as parameter.
How can i check if this session active? How can i check userdata associated with this session
Can someone please send example code?


Thank You
ClaiborneClaiborne

Try this . . .

Code:

<—php
        // This code assumes that the call from salesforce.com has the variables location and sessionId.
        // Also, the partner wsdl has been downloaded and stored locally.      
    $wsdl = 'partner.wsdl.xml';
    
    require_once ('soapclient/SforcePartnerClient.php');
    require_once ('soapclient/SforceHeaderOptions.php');

        // Establish client to sfdc 
    $client = new SforcePartnerClient();
    $client->createConnection($wsdl);
    $client->sessionId = $_REQUEST['sessionId'];
    $client->setSessionHeader($client->sessionId);
    $client->setEndpoint($_REQUEST['location']);
    
        // Retrieve the user info
    $result = $client->getUserInfo();

    $SFid = $result->userId;
    $uiSkin = $result->userUiSkin;
    $fullName = $result->userFullName;
    $locale = $result->userLocale;
    $language = $result->userLanguage;
    $SFaccountId = $result->organizationId;
    $email = $result->userEmail;
    $accountName = $result->organizationName;
–>


 

evgenykaevgenyka
Thanks
evgenykaevgenyka
I am getting following error

Fatal error: Cannot access protected property SforcePartnerClient::$sessionId in /oracle_general/SF/synch/synch/sftest.php on line 12