• 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

Project structure for PHP

java URL working on browser but not in client program

IlluminateDatabaseQueryException could not find driver [duplicate]

Unable to guess the mime type as no guessers are available Laravel 5.2

target [LaravelFortifyContractsRegisterViewResponse] is not instantiable

Currently Using CodeIgniter Framework i have an Error

CodeIgniter 3 is generating a session file on each request, why?

ConstraintViolationListInterface to Exception in Symfony

How do I truncate a decimal in PHP?

PHP drop down list using array's and foreach (else and for) code

Transpose csv file data [duplicate]

Add rows to Single product Additional information table in WooCommerce 3.6

PHP sort array of objects by two properties

javascript html popup window

Laravel s3 upload file with metadata using pre-signed url

About Contact Privacy policy Terms and conditions