• 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

WordPress - Dynamically add user ID to the end of a URL

"Notice: Undefined variable", "Notice: Undefined index", "Warning: Undefined array key", and "Notice: Undefined offset" using PHP

Increase value by 1 on button click

How to find phpcs current default standard

SlimExceptionHttpNotFoundException

Log file is not being written in Laravel 5.5

Why do I have invalid argument supply for foreach in Laravel for json response? [duplicate]

500 (Internal Server Error) with Laravel & Docker [duplicate]

I want to display a sweetalert after the inserting of data in my database

Extract string between first whitespace and last whitespace in php

add " ? " in url via htaccess RewriteRule

how to display a view on laravel 8 and not have a 404 NOT FOUND page?

How to use $this->session->set_userdata in codeigniter

What is my SQL missing?

Sum array values of a column within each column of an array with 3 levels

About Contact Privacy policy Terms and conditions