CRM-15103 fix - Priceset for memberships on contribution-page not working
[civicrm-core.git] / CRM / Core / Session.php
index 7390bd19599e979cc134add6cf76176417837659..b31782dfad49bfaf0957880ce7d1978018a1dfe0 100644 (file)
@@ -119,7 +119,11 @@ class CRM_Core_Session {
         }
         $config =& CRM_Core_Config::singleton();
         if ($config->userSystem->is_drupal && function_exists('drupal_session_start')) {
-          drupal_session_start();
+          // https://issues.civicrm.org/jira/browse/CRM-14356
+          if (! (isset($GLOBALS['lazy_session']) && $GLOBALS['lazy_session'] == true)) {
+            drupal_session_start();
+          }
+          $_SESSION = array();
         }
         else {
           session_start();
@@ -541,6 +545,18 @@ class CRM_Core_Session {
     self::$_managedNames = NULL;
   }
 
+  /**
+   * Retrieve contact id of the logged in user
+   * @return integer | NULL contact ID of logged in user
+   */
+  static function getLoggedInContactID() {
+    $session = CRM_Core_Session::singleton();
+    if (!is_numeric($session->get('userID'))) {
+      return NULL;
+    }
+    return $session->get('userID');
+  }
+
   function isEmpty() {
     // check if session is empty, if so we dont cache
     // stuff that we can get away with