Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sessions]

Use it for questions about the session system, which handles recognizing users from a session cookie.

1
vote
0answers
41 views

Same session variable retrieved in different blocks not stable

I have a module that have three blocks. Block No 1 sets the session Block No 2 gets the session Block No 3 remove the session Each block is assigned to a different page. Now, for some reason this ...
0
votes
2answers
64 views

Is it possible to unset private_tempstore values?

I have a block that creates a private_tempstore value (which I understand works exactly like PHP sessions). How do I unset that value. This is the code I am using for the block. class ...
5
votes
1answer
150 views

How does core triggers cleanup of expired sessions in database?

core/lib/Drupal/Core/Session/SessionHandler.php defines a method (gc()) to clear expired sessions from the database (sessions table) when is that triggered ? is there a way to trigger it from the ...
2
votes
2answers
57 views

Force redirect back to password form until password got set after one-time-login

When my users click on a one-time-password-reset link then I log them in and then show them a page where they can choose their new password. Problem is that there are two additional links on that page ...
1
vote
1answer
124 views

Switch user session programmatically

I'm trying to switch user session thanks to Drupal Switch. I want to do this so that when I have a certain role, I can switch to another user account to check some data from the user i choose to ...
0
votes
0answers
14 views

How to hit an endpoint (menu route) with the session intact

I'm trying to hit an endpoint which shows different data when logged in/out. I am trying to write a unit test, but can't seem to figure out how to hit the end point with user context. How can I do ...
4
votes
1answer
89 views

What is the difference between a Drupal session variable and a cookie?

When you set a Drupal session variable (i.e. a "magic" variable you may set like this): $_SESSION['mymodule'] = array('key' => 'value'); the value goes away when the user logs out. If you set a ...
0
votes
1answer
316 views

Rest login cookie token explanation

When logging in via a POST to user/login?_format=json I'm sent back a response that looks like this { "current_user": { "uid": "233", "name": "test" }, "csrf_token": "...
0
votes
1answer
29 views

How do I keep data without using sessions

Is there a way to store data for separate users in Drupal without using sessions. I have previously used Drupal varibales. But it didin't work because the variable gets updated for every user (So ...
0
votes
0answers
64 views

Session Fails to Start

In my drupal site, it has been working fine for a while, but recently users have not been able to log in to the site (including me as admin). I am seeing the following error in my php logs: [28-Jul-...
0
votes
1answer
129 views

Access denied for all users, sessions table empty, access log shows NULL uid

My Drupal 7 site has been up and running for a couple years without issue. I went to log in as admin today to check for security updates and had the following experience: When I first browse to the ...
0
votes
0answers
62 views

Access Private Tempstore for anonymous user after registration

I try to use the private temp store for anonmyous users, and store information, here only a unique id, but afterwards more information of course. This works. When the user registers the information ...
1
vote
1answer
720 views

How to access session variables in Twig template?

In a custom module I specified in the hook_preprocess_page function the following session variable: if (isset($blockNameState) && $blockNameState == 'open') { $tempstore->set($...
0
votes
1answer
29 views

Is a session alone enough for non logged-in users to see some information?

In my project I have a content type called Person that is only viewable or editable by logged-in user. In this content type, I added some fields. I want to give a person the ability to visit his ...
0
votes
0answers
39 views

hook_node_access() is not called with anonymous users

I have created a content type that only authenticated users with specific roles are permitted to view or edit, but in some cases I want to give permission to anonymous users to see specific nodes. ...
1
vote
1answer
75 views

Drupal 8 reset session each request

I have create a EventSubscriber like this: <?php namespace Drupal\custom_session\EventSubscriber; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\...
0
votes
0answers
153 views

How can I get rest/session/token when using Guzzle from outside Drupal?

I'm writing a small Guzzle based script that parses a json extract and then pushes the data into Drupal 8 via the REST api. Everything I've tried in Guzzle to get the rest/session/token or session/...
0
votes
0answers
95 views

How to make anonymous session data private

I am using this multi-step form example (https://www.sitepoint.com/how-to-build-multi-step-forms-in-drupal-8/ ) for the basis of an online employment application using Drupal 8. All applicants are ...
0
votes
0answers
31 views

Session id being saved to database is different than session id being stored in the cookies

I started experiencing a login issue with my Drupal site where a login succeeds and then immediately fails. I've traced the code using xdebug and found that what seems to be happening is that login ...
0
votes
3answers
62 views

Run code when a session ends

Is there a hook or something similar that triggers when a PHP session ends? When a user signs in, I'm writing a few things to the cache, and I need to delete them from the cache when the user exists ...
0
votes
0answers
63 views

Anonymous session not initializing properly in iframe

I have an iframe that loads a url (defined by hook_menu) that returns html and is supposed to check if a session for the anonymous user exists, if not, a session is started using session_id() Once ...
0
votes
0answers
39 views

How do I save data using session?

I'm looking for a way to save a data from hook_cron() and then call that data on my controller that is being called by my API request. I tried using the following code to store data. $tempstore = \...
-1
votes
2answers
58 views

Clear session on checkout complete

I'm using the following code to remember shopping carts per session. The code works just fine, but the problem is that the cart is not emptied on checkout complete, but shows the contents of the ...
1
vote
3answers
116 views

How to implement a button with different redirections?

I'm setting up a job directory using Drupal 8, together with a team. It is possible to see it here. As you can see below, in a screenshot of the site, there's a button called "Add new job": In a ...
4
votes
2answers
866 views

Increase session timeout

So I have a requirement that I'm getting close to stumped on how to complete in Drupal 8. I'm going to attempt to simplify the requirements. I have two roles. They are essentially mutually exclusive. ...
-1
votes
1answer
28 views

Register a custom AttributeBag to the SessionManager

How can I register a new custom AttributeBag into the session manager? I have this custom module and want to contain the session stuff in a specific attributeBag. But when I try to call the ...
1
vote
2answers
36 views

View content based on if a new session is created

I am running a Drupal 7 website using the Ubercart module. I am trying to show some HTML content when users get on the site, and not keep viewing it when they click on a certain button. I need this ...
0
votes
0answers
315 views

Getting query parameters after redirect

I am having trouble setting up a function to get the query parameters from a url when the url changes when loading the page. For a client we need to send out Affiliate mailings that use other links (...
0
votes
0answers
91 views

Anonymous session data is being carried over for another user

I am saving form values to a session variable for anonymous users in a WebformHandler using the following code: $values = $form_state->getValues(); // set session vars $session = \Drupal::request()...
0
votes
1answer
102 views

How to write session data for another user?

I need to switch to another user, create session for him, write data into the session(his UID), save the session id, then switch back to original user and work with the session id. The account ...
2
votes
0answers
287 views

D8 use Memcache for sessions only

I need to use memcache only for sessions. We have PHP 7.1, php-memcached and Drupal 8 with Memcache module. In session.php we put: $settings['memcache']['servers'] = ['192.168.177.112:11211' => '...
3
votes
1answer
502 views

Reasons for limited login duration?

On a site I am working on, I get logged out almost daily. I assume there is a limit on the login duration. I already set session.gc_maxlifetime to a very high value, using ini_set() in settings.php. ...
1
vote
0answers
330 views

Decoupled session token login issue

I'm new to react and Drupal. I run into the following 403 error in my reactjs login code. I'm using a custom authentication method that I have working, at least using Postman. I also have it working ...
1
vote
1answer
530 views

How to handle session for anonymous users for CSRF tokens?

I need to provide list of CSRF tokens in drupalSettings for every anonymous user so JS can make safe requests to api endpoints. The CSRF service mentions the need for session to exist for the seed ...
2
votes
2answers
124 views

How to change client session variables during a functional browser test?

I have a session variable, that once set changes block output of the system branding block. Normally this variable is intercepted from the query string by an inbound path processor, however that is a ...
0
votes
2answers
100 views

Cannot log in to Drupal running alongside WordPress multi-site

I have a Drupal site (7) that I've migrated to a new server. I have a WordPress multi-site install on this server that looks like this at the moment: example.com store.example.com I used to have a ...
2
votes
2answers
558 views

Restoring tempstore with another session ID

I am building the functionality of sign in during payment checkout in Drupal 8, and I am storing all the values in Drupal 8's tempstore variable. I am capturing the session id for this anonymous user. ...
0
votes
1answer
41 views

Force a session to become HTTPS?

I'm working with a very complex legacy D7 site, and very complex requirements (bleaugh). Anyway: I'm working on a deeplinking system that allows a jump to the site, which then logs-in a user (this is ...
-1
votes
1answer
722 views

Session not refreshing until the cache is cleared

I am trying to store data entered in the drupal custom form in order to display it in next page using session. For the first time it is running perfectly, but for the second time it contains the ...
0
votes
1answer
492 views

how to secure session cookie in drupal7

I am facing a session cookie hijacking vulnerability please refer the attached image. When i put these cookie in another browser which i simply type the domain like http://example.com and add ...
4
votes
1answer
449 views

When user.private_tempstore gets deleted

I've read about the \Drupal::service('user.private_tempstore')->get('mymodule_name'); and found similar to storing data in $_SESSION. I am using user.private_tempstore in my module to store some ...
0
votes
1answer
104 views

Is there a way to set a session variable but not save them in the sessions table?

I wanted to save a huge array in a $_SESSION variable. If I understand it correctly, Drupal saves the entire $_SESSION into the sessions table. But when the $_SESSION variable gets to around 3mb, ...
0
votes
1answer
76 views

How do I access $_SESSION in a view?

Let's say I want to use $_SESSION['user_variable'] with a view as a filter value. I read that in Drupal 7 I could add such a value with custom PHP code. How should I do in Drupal 8? I didn't find an ...
1
vote
1answer
189 views

Session ID same across browsers

I know that it's impossible for the sessions IDs to be the same across multiple browsers, but Drupal is acting really weird with sessions and I've been stuck with this issue for over a week now. Let ...
1
vote
0answers
161 views

Hashing function for session

I need to verify the users session of Drupal on a Node.js server. The session ID has been hashed and it is stored in the Drupal 8 database. How can I hash the browsers session ID to compare it with ...
3
votes
1answer
972 views

How does Drupal verify sessions from the cookie value?

Sorry, I know it's weird, but I'm trying to integrate another php application with Drupal. I want to know if the user is currently logged in to the Drupal site, even though the request is going ...
2
votes
1answer
144 views

Drupal sessions in angular app [closed]

I'm developing an angular application which uses drupal as a backend. When user login to my webapp, they can able to get some data from the drupal backend. Also, I'm maintaining a session for that ...
0
votes
1answer
42 views

How can use session

I created a html page and create form on it . I want send data of my form to a form that I create . I use session but when I use session and refresh page , other session was delete or when i use ...
0
votes
0answers
46 views

What is the problem in my code ? [ SESSION ]

I create a code for my form . When I choose a product in node,data send to my form page and sessions sav data and then I chose seconde product I see two products in my form page . But when I refresh ...
5
votes
1answer
655 views

How does drupal set user cookie

The following code, let's login any user programmatically. global $user; $user = user_load(<any_uid>); My question is how does the above code triggers to set new user cookies on browser, at ...