• 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

PHP only Hit Counter?

google content api for shopping

Implode columnar values between two arrays into a flat array of concatenated strings

How to get Laravel's CSRF Token from Another Website?

Facebook PHP SDK - will not logout properly

Why does codeigniter & Linux server throws unserialize() session data error when user tries to login

I can't delete my image when it is liked because of the foreign key in mysql

How to give apache permission to write to home directory?

Woocommerce product attributes with hierarchy like categories

How to install PHP composer inside a docker container

PHPExcel file download using AJAX call

User pool client {id}does not exist

PHP: How to solve ob_start() in combination imagepng() issue?

Need to display only array value in JSON output

Split array into 4-element chunks then implode into strings

About Contact Privacy policy Terms and conditions