From a9bb592598cce33167df6468067dd11d8ea669b6 Mon Sep 17 00:00:00 2001
From: Dan Chadwick <dan899@gmail.com>
Date: Tue, 8 Sep 2015 21:12:47 -0400
Subject: [PATCH] Issue #2555119 by DanChadwick: Provide session when any
 submission link has passed token access.

---
 webform.module |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/webform.module b/webform.module
index f631598..08c6a61 100644
--- a/webform.module
+++ b/webform.module
@@ -616,6 +616,12 @@ function webform_submission_access($node, $submission, $op = 'view', $account =
 
   $token_access = $submission && isset($_GET['token']) && $_GET['token'] == webform_get_submission_access_token($submission);
 
+  // If access is granted via a token, then allow subsequent submission access
+  // for anonymous users.
+  if (!$user->uid && $token_access) {
+    $_SESSION['webform_submission'][$submission->sid] = $node->nid;
+  }
+
   $general_access = $access_all || $access_own_submission || $access_node_submissions || $token_access;
 
   // Disable the page cache for anonymous users in this access callback,
@@ -3310,7 +3316,7 @@ function webform_client_form_submit($form, &$form_state) {
     // Save session information about this submission for anonymous users,
     // allowing them to access or edit their submissions.
     if (!$user->uid && user_access('access own webform submissions')) {
-      $_SESSION['webform_submission'][$form_state['values']['details']['sid']] = $node->nid;
+      $_SESSION['webform_submission'][$sid] = $node->nid;
     }
   }
   else {
-- 
1.7.8.msysgit.0

