diff --git a/core/includes/common.inc b/core/includes/common.inc
index bd263ec..7c32089 100644
--- a/core/includes/common.inc
+++ b/core/includes/common.inc
@@ -4712,9 +4712,9 @@ function drupal_json_decode($var) {
  *   The private key.
  */
 function drupal_get_private_key() {
-  if (!($key = variable_get('drupal_private_key', 0))) {
+  if (!($key = state()->get('system.private_key'))) {
     $key = drupal_hash_base64(drupal_random_bytes(55));
-    variable_set('drupal_private_key', $key);
+    state()->set('system.private_key', $key);
   }
   return $key;
 }
diff --git a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
index 4fb1f68..ffa786f 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Upgrade/StateSystemUpgradePathTest.php
@@ -59,6 +59,10 @@ public function testSystemVariableUpgrade() {
       'value' => 'kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M',
       'variable_name' => 'cron_key',
     );
+    $expected_state['system.private_key'] = array(
+      'value' => 'G38mKqASKus8VGMkMzVuXImYbzspCQ1iRT2iEZpMYmQ',
+      'variable_name' => 'drupal_private_key',
+    );
     $expected_state['tracker.index_nid'] = array(
       'value' => 0,
       'variable_name' => 'tracker_index_nid',
diff --git a/core/modules/system/system.install b/core/modules/system/system.install
index ca5d6de..9b676d3 100644
--- a/core/modules/system/system.install
+++ b/core/modules/system/system.install
@@ -2195,6 +2195,17 @@ function system_update_8045() {
 }
 
 /**
+ * Moves drupal_private_key variable to state.
+ *
+ * @ingroup config_upgrade
+ */
+function system_update_8046() {
+  update_variables_to_state(array(
+    'drupal_private_key' => 'system.private_key',
+  ));
+}
+
+/**
  * @} End of "defgroup updates-7.x-to-8.x".
  * The next series of updates should start at 9000.
  */
diff --git a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
index a6f47ef..605ca5c 100644
--- a/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
+++ b/core/modules/system/tests/upgrade/drupal-7.state.system.database.php
@@ -48,6 +48,10 @@
   ->fields(array('value' => serialize('kdm95qppDDlyZrcUOx453YwQqDA4DNmxi4VQcxzFU9M')))
   ->execute();
 db_merge('variable')
+  ->key(array('name' => 'drupal_private_key'))
+  ->fields(array('value' => serialize('G38mKqASKus8VGMkMzVuXImYbzspCQ1iRT2iEZpMYmQ')))
+  ->execute();
+db_merge('variable')
   ->key(array('name' => 'node_cron_comments_scale'))
   ->fields(array('value' => serialize(1.0 / 1000)))
   ->execute();
