Answers.Body: <p>You can try </p>
  
  <p>-- Variable to set in CiviCRM session 
  <code>
  CRM_Core_Session::singleton()->set('myVariable', 'Yes, I am in current Session');
  </code></p>
  
  <p>-- get value of variable from CiviCRM Session
  <code>
  CRM_Core_Session::singleton()->get('myVariable');
  </code></p>
  
  <p>HTH<br>
  Pradeep</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-21T12:28:02.913Z
Answers.LastActivityDate: 2016-07-21T12:28:02.913Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I can't seem to access session values on API definition. <code>var_dump($_SESSION)</code> returns an empty array event after putting <code>session_start()</code>.</p>
  
  <p><code>api/v3/MymoduleEntity.php</code></p>
  
  <pre><code>function civicrm_api3_mymodule_entity_method($params) {
    session_start();
    return var_dump($_SESSION); // Returns an empty array
    ...
  }
  </code></pre>
  
Tags: <api><session>
Title: Can't seem to access Session values in module's API file
ThreadText: # Can't seem to access Session values in module's API file
  
  (Asked by: username_0 on 2016-06-22)
  
  I can't seem to access session values on API definition. var_dump($_SESSION) returns an empty array event after putting session_start().
  api/v3/MymoduleEntity.php
  function civicrm_api3_mymodule_entity_method($params) {
    session_start();
    return var_dump($_SESSION); // Returns an empty array
    ...
  }
  
  **Tags:** api, session
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2016-07-21. Score: 1 | Accepted answer
  
  You can try
  
  -- Variable to set in CiviCRM session
  `CRM_Core_Session::singleton()->set('myVariable', 'Yes, I am in current Session');`
  
  -- get value of variable from CiviCRM Session
  `CRM_Core_Session::singleton()->get('myVariable');`
  
  HTH  
  Pradeep
  
  
  ---
  
  