• 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

How to identify whether webp image is static or animated?

carbon generated datetime not stored correctly into the database

In PHP, which is faster: preg_split or explode?

Prevent blank space in pdf pages (DomPdf)

Laravel/docker-compose/redis - Class 'Redis' not found

how to youtube api data to print in toolset metabox using a button click before save-post

php code to send checkbox form results to email

PHPSpreadsheet - How Do I Use Auto Migration Tool

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

No result using makeStyles Material UI in react 18

PhpSpreadSheet: How to save Workbook sheets in individual CSV files

Can we define variables in `.tpl` files?

Confirm Leave on External Links in Wordpress

Magento 2 - Controller returning blank page

PHP rotate matrix counter-clockwise

About Contact Privacy policy Terms and conditions