• 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

Read users and passwords from a txt file

Transform array, set each array element with parent key php

PHP -> Next nearest date defined by array of days in week

Log file is not being written in Laravel 5.5

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

Download & Save Zoom Recording in directory by PHP

Valet, Xdebug after reboot Big Sur not working

Not able to override collapsible.js in magento 2

Create a new line whenever an array value reaches more than 10 characters

PHPSpreadsheet - How Do I Use Auto Migration Tool

Target Laravelista is not instantiable

Sort a multidimensional array by integer inside of a string value which is two levels down

Symfony 4: how to allow dynamic values for array nodes in bundle configuration?

Add Class in html Dynamically in PHP

Unit (real unit test) of test laravel relationship

About Contact Privacy policy Terms and conditions