• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

how can I set a session variable in Drupal 8 and get it in a php script?

phpsessiondrupalsession-variables


PHP Snippet 1:

$tempstore = \Drupal::service('tempstore.private')->get('your_module_name');
$tempstore->set('value', 'hi');

PHP Snippet 2:

$tempstore = \Drupal::service('tempstore.private')->get('your_module_name');
$some_data = $tempstore->get('value');

Related Snippets

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

Timber: Single post pagination does not work (wp_link_pages)

Trying to iterate over a mongodb cursor twice - failing

Symfony redirect if already loggedin from login page

Symfony Error: "An exception has been thrown during the rendering of a template"

Session timeout in Yii2

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

"There is no active transaction" when refreshing database in Laravel 8.0 test

Merge key and value of array index [duplicate]

CodeIgniter force_download is not working

str_word_count() function doesn't display Arabic language properly

Transform array, set each array element with parent key php

PHP my timezone is no setting up in PHP.ini File in xampp

Zig-zag scan an N x N array

php echo xml documents with header

About Contact Privacy policy Terms and conditions