• 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

Group rows by column and sum another column within groups [duplicate]

Debugging Stripe Webhook Event

How to set time with DateTime modify?

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

How can I make a full text index of the column?

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

find in set in laravel ? example

Phalcon: setStatusCode returns empty response

How to prevent phpmailer sending embedded image as an attachment on Gmail?

Ajax GET request fails in laravel 8

Remove country code from phone number?

How to validate Envato Purchase Code in PHP

Stop caching for PHP 5.5.3 in MAMP

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

How to get AJAX to post on second page?

About Contact Privacy policy Terms and conditions