• 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

Accessors (Getter) & Mutators (Setter) On a Pivot Table in Laravel

Input and output values for php into the browser?

Attempted to call an undefined method named "get" of class "MailController"

mysql slow on updates for a well optimized query

dompdf and img tag, image wont show

Failed user login on production server using Symfony framework (Authentication request could not be processed due to...)

WooCommerce - unset "<product> removed notice…" on cart page

XML to CSV with PHP converter [problem with images grabing]

XSS attack still works despite htmlspecialchars() doing its work

Exact alternate to mcrypt_encrypt in PHP 7.2

Why does using salted hash on python and php give me different results?

PHP Warning: Module already loaded in Unknown on line 0

Sum array values

PHP to search within txt file and echo the whole line

Laravel: Why is my variable not being set while it's in the construct function of the controller?

About Contact Privacy policy Terms and conditions