• 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

Popup Window and PHP form

add uri parameter to Route name in laravel

401 Unauthorized only occurring on some pages in Laravel 8

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

Auto increment id JSON

HTML + PHP + PHPMAILER

TesseractOCR not working for Laravel

Can I write PHP code across multiple lines per statement?

Add a custom text for a particular product on specific email notification in Woocommerce

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

WAMP Virtual Host not working

How do I enable error reporting in Laravel?

How To Access A Column In M-M Relationship Table In Laravel

Insert multidimensional array to codeigniter cart

How to KeyBy where multiple items have the same key

About Contact Privacy policy Terms and conditions