• 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

Call to a member function givePermissionTo() on null

how to validate form data in codeigniter 4

Can I write PHP code across multiple lines per statement?

RabbitMQ PRECONDITION_FAILED - unknown delivery tag

phpMyAdmin ERROR: mysqli_real_connect(): (HY000/1045): Access denied for user 'pma'@'localhost' (using password: NO)

Adding multiple items to WooCommerce cart at once

OctoberCMS / Anonymous Global Scope

Read users and passwords from a txt file

How to get quarter for future date using Carbon?

How to pass security cloudflare server with php curl

How to edit Records using CodeIgniter

file_get_contents() without "Http" to access external URL [closed]

onKeyUp event calculation not working on the following rows from php generated forms except the first one

PHPUnit 7: Failed asserting that exception of type InvalidArgumentException is thrown

Laravel Delete and Update

About Contact Privacy policy Terms and conditions