• 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

Fatal error: Uncaught TypeError: count(): Argument #1 ($var) must be of type Countable|array, null given in

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

Mobile browsers are adding .html to filename on download

Sort multidimensional array by column value within a column

Dynamic dropdown Ajax PHP request

How to test a php login connected to a mysql db through xampp?

How to make a array inside array?

How to test laravel controller method?

Hi, I am making a contact form thingy, and my php isn't working any reason why?

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

Change the alert text on add to cart action without selected variation in Woocommerce

Laravel 8 Multiple Relationships for Factory

php code to send checkbox form results to email

Reading input in php from terminal

Can't find vendor/autoload.php for Ratchet

About Contact Privacy policy Terms and conditions