• 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

Wordpress how to get the post thumbnail inside a figure tag

getting error while enter Command => php artisan route:list

How to override header set in Apache config with more specific header in a virtual host

Autoloading classes in PHPUnit using Composer and autoload.php

PHP Get value from JSON [duplicate]

Yii2: How to download backup files using spanjeta/yii2-backup?

MongoDB Duplicate Documents even after adding unique key

Generate random username based on full name php

How to get AJAX to post on second page?

Backend cannot be reached after Typo3 login screen

carbon generated datetime not stored correctly into the database

Assign output of PHP function to a variable

How to find the date a user created their Google account

Get data from accuweather api url

wp_remote_get() not passing authentication

About Contact Privacy policy Terms and conditions