• 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

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

Submitting a form with ajax in Wordpress

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Display specific shipping method if woocommerce product has specific acf field value

How to convert time from one timezone to another in PHP

laravel sanctum Route [login] not defined

Can't remotely connect to MySQL error (13) with PHP script, connecting through CLI works

PHP drop down list using array's and foreach (else and for) code

Eloquent insert id with sequence next value

Coinpayments create_transaction "ERROR: Invalid command!"

Can we define variables in `.tpl` files?

Get number of working days between two dates in PHP [duplicate]

Laravel 5 issue with wherePivot

Add and update products to session cart in Laravel

About Contact Privacy policy Terms and conditions