• 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 insert data into select2 search input after scan using qrcode

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

storagelogs/laravel.log" could not be opened in append mode: failed to open stream: Permission denied

How can I access an array/object?

Converting IPv6 to IPv4 address in PHP

str_word_count() function doesn't display Arabic language properly

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

dompdf and img tag, image wont show

How to validate tin and cst using PHP?

PHP Imap , php 7.4.3 on mac osx catalina

PHP using str_starts_with for array to exclude same as with wildcard

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

Parsing JSON File to array in PHP

Converting array to string and then back in PHP

About Contact Privacy policy Terms and conditions