From 083cedd26b518063689e7574f0e010d247b31679 Mon Sep 17 00:00:00 2001
From: Bram Goffings <bramgoffings@gmail.com>
Date: Sun, 25 Mar 2012 19:05:33 +0200
Subject: [PATCH] Issue #1492508 by ajevans85: Fixed DeploAuthenticatorSession
 login issue.

---
 plugins/DeployAuthenticatorSession.inc |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/plugins/DeployAuthenticatorSession.inc b/plugins/DeployAuthenticatorSession.inc
index 298b31b..fc033d4 100644
--- a/plugins/DeployAuthenticatorSession.inc
+++ b/plugins/DeployAuthenticatorSession.inc
@@ -53,13 +53,13 @@ class DeployAuthenticatorSession implements DeployAuthenticator {
       if (isset($response->error) || !in_array($response->code, array(200, 304))) {
         throw new DeployAuthenticationException(t('Authentication error: @code @error', array('@code' => $response->code, '@error' => $response->error)));
       }
-      if (!empty($response->headers['set-cookie'])) {
-        // Set the session cookie, retrieved from the login request on the
-        // endpoint, for all calls made by the service.
-        $this->service->config['headers']['Cookie'] = $response->headers['set-cookie'];
-      }
-      else {
-        throw new DeployAuthenticationException(t("No 'set-cookie' header was returned from the authentication request."));
+
+      $response_data = drupal_json_decode($response->data);
+
+      if ($response_data['session_name'] && $response_data['sessid']) {
+        $this->service->config['headers']['Cookie'] = $response_data['session_name'] . "=" . $response_data['sessid'] . ";";
+      } else {
+        throw new DeployAuthenticationException(t("No session was returned from the authentication request."));
       }
     }
     else {
-- 
1.7.5.4

