• 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

How to break out of a foreach once a condition is met?

Call to a member function fetch_field() on a non-object MySQLiDB

Woocommerce product attributes with hierarchy like categories

How do I upload a laravel project on cPanel shared hosting?

Add customer email and phone in "Order" column to admin orders list on Woocommerce

Navigation idle on content download

*** ERROR *** The PHP configuration loaded file is: c:/wamp64/bin/php/php8.1.0/php.ini - should be: c:/wamp64/bin/apache/apache2.4.53.1/bin/php.ini

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Transpose and flatten two-dimensional indexed array where rows may not be of equal length

Is there a way to use Foundry Model for Authentification inside Functional Tests?

How to show selected value using javascript in laravel

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

How to loop a tree array with unknown depth and get array blocks?

Wordpress how to get the post thumbnail inside a figure tag

Make Calculator - When Button clicked the No shows in Textbox.

About Contact Privacy policy Terms and conditions