• 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

Laravel - Browser displays message again when I press back button

possible options to create pdf file using html elements to generate invoice in php and codeigniter

Check if string contains a value in array [duplicate]

Zig-zag scan an N x N array

Boolean assignment operators in PHP

PHP: Telegram Bot: Insert line break to text message

PHP Find Array Index value in multi-line array

Search for array row with specific column value and return another value from qualifying row

Destroy session upon refresh

Execute only one time and then wait set period of time before executing again

Facebook PHP SDK - will not logout properly

Use Python plotly chart in PHP

Getting public posts of a random user from Facebook API

Multiple order by in WooCommerce

LARAVEL: How to fetch id dynamically in a query builder?

About Contact Privacy policy Terms and conditions