• 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 no logout option from menu after successfull login

How to delete old images from public folder on update using Laravel

Cannot connect to own websocket server when on secured domain

how to redirect the user back to desired URL after login page in PHP?

Yii2 redirecting to previous page after login

Laravel UUID generation

Laravel get user data with profile

Post Form Data To phpmyadmin Database

xdebug 3 not working in ubuntu 20.04 with docker

Display specific shipping method if woocommerce product has specific acf field value

Webscraping Symfony/Panther: Can't get HTML

Losing session data after POST from third party website

Laravel dosen't connect with Oracle

The difference when using if statement true === something() vs something() === true [duplicate]

Elasticsearch - Want to sort by field in all indices where that particular field available or not if not then avoid it

About Contact Privacy policy Terms and conditions