Skip to main content

Questions tagged [sessions]

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

Filter by
Sorted by
Tagged with
0 votes
1 answer
1k views

Private tempstore storage contains data for previous anonymous user

I have an issue with private tempstore storage that I wasn't able to solve. I've implemented a webform handler, which populates data in this storage and then I'm creating tokens out of the saved ...
2 votes
2 answers
13k views

How to access session in twig?

I wondering how to access to session in twig ? In my Controller I have this part of code : $tempstore = \Drupal::service('user.private_tempstore')->get('mdm_user'); $tempstore->set('...
3 votes
1 answer
1k views

Is it possible to set Cookie Session ID from a REST Service?

I have overridden Drupal's login process by calling a REST API which returns a 'true' or a 'false' depending on whether the login was successful or not. Once successful, I'm logging the user in by ...
2 votes
1 answer
502 views

Persistent anonymous user session with headless D9

In short: a new php session is started upon every request made through nextjs, I somehow must keep the anonymous user session alive. For my anonymous users I need keep track of data submitted through ...
0 votes
2 answers
2k 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
1 answer
986 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
0 answers
44 views

I cant get the session

I m beginner on drupal, and i have a problem with session. I created a custom form submission inside the clubs module. namespace Drupal\idan_login\Form; // Form submission handler. public function ...
2 votes
1 answer
520 views

Multipage Registration form, Confirmation Page Security Issues?

I have a multipage registration form working on a site, but the confirmation page is supposed to show some of the information (account name and other data) after the account has been submitted/created....
3 votes
3 answers
3k views

How to add onclick event to a link?

I need to create a link, which when clicked should be able to set a session variable. I have used l() function to create the link and tried this but this is not working. 'name' => l(t($n['name']),...
0 votes
1 answer
3k views

How to set a session variable when a link is clicked?

I have created a search block. It outputs multiple results (names) as links. User can follow the link. How can I pass the user name into $_SESSION variable? I tried doing this, the result shows a page ...
2 votes
1 answer
1k views

How to handle session for anonymous users for CSRF tokens?

I need to provide a list of CSRF tokens in drupalSettings for every anonymous user to make safe requests to API endpoints. The CSRF service mentions the need for session to exist for the seed, but I ...
4 votes
1 answer
1k views

Additional Configuration to disable anonymous session cookies?

I am running a clean install of Pressflow 6.28. I have set the following configurations: Cache Mode: Normal; Min Cache Lifetime: 5 minutes; Page Cache Max Age: 1 day; I have installed no contributed ...
0 votes
3 answers
1k views

Redirect to page before login

Now i know there are some ways that a redirect on login can be setup, ie using views etc, but i think my issue maybe a bit more complicated. When a user accesses a node for example where they are ...
1 vote
1 answer
289 views

Using a session for anonymous users

I set some session data for a user I auto logged out. Then tried to retrieve that session data in a form validation. It is not there. class MFAController extends ControllerBase { public function ...
3 votes
1 answer
76 views

Drupal unable to login and logout several accounts in a single functional test

I am trying to run some functional tests in DDEV that check functions of protected routes. I can log in the first couple of users fine, but after that drupaLogin() fails to generate a logged in ...
3 votes
1 answer
636 views

Is there an event related to the creation of a session cookie for anonymous users?

I need to set an additional cookie whenever an anonymous user received a session cookie. This happens when selecting a facet in Search API for example. The specific use case is that I need an extra ...
0 votes
1 answer
1k views

How to know Active sessions in Drupal?

Is there any way to find my opened/active sessions and close them in Drupal? If there is already a session for the logged-in user, a notification like the following should be shown. Open in 1 other ...
0 votes
0 answers
64 views

TFA Session expired when user login

not sure if anyone faces this issue, when I tried to login with the authentication. It shows TFA session has expired. But the user account was logged in. Screenshot attached, I tried to drupal set ...
17 votes
2 answers
26k views

Understanding Drupal's session management and user authentication

I have a requirement to replace the default user authentication with the authentication of a central server, i.e., the SSO server. By debugging Drupal, I learned that all the session management ...
0 votes
0 answers
225 views

Messenger doesn't display value after user logged out and redirect

After my user is submitting a form, I want to logged him out, then redirect to the front page. then, display a message. public function submitForm(array &$form, FormStateInterface $form_state) { ...
2 votes
1 answer
439 views

Twitter sign in module session token values lost in twitter/oauth path in HTTPS - Invalid Twitter OAuth request

The twitter sign in module works on my local and staging server on HTTP fine. But when I install the same module in production mode which is https://example.com, it stops working. The error says "...
7 votes
4 answers
6k views

What is the right way to force a session start?

I'm currently porting SimpleFBConnect module to Drupal 8. This module uses Facebook PHP SDK which expects that we have established a session before the user is redirected to Facebook for ...
0 votes
0 answers
88 views

Login fails: returns to anonymous user home page with no message

I am testing upgrade to Drupal 9. I upgraded core and logged in and fixed a few issues with module deprecated code and then was presented with a Twig issue where replace syntax had changed. I changed ...
1 vote
1 answer
2k views

How can I share session variables across sites? [closed]

On my main Drupal site, users need to be able to select a display preference (e.g. 'high visibility'). This will be available to registered and anonymous users but only for their session, so I plan to ...
2 votes
2 answers
131 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 ...
20 votes
6 answers
26k views

Storing data / session for anonymous user

I am working on a shop, and for the cart, i need to store items before payment. $tempstore = \Drupal::service('user.private_tempstore')->get('boutique'); $tempstore->set('poids', $...
0 votes
1 answer
736 views

Site stuck in 'headers have already been sent' login loop after D9 upgrade

Suggestions for debugging a site which is now stuck in a "headers have already been sent" loop after successful login (redirect back to login form)? This is a production server for a site ...
3 votes
1 answer
649 views

Can I use the session service directly instead of via the request?

The Drupal documentation on sessions mentions that sessions can be accessed via the Request object: Session data is accessed via the \Symfony\Component\HttpFoundation\Request::getSession() method, ...
8 votes
2 answers
9k views

No one can login and access denied message

The site worked till yesterday and just now it's behaving strangely. The site is not created with features, an archive dump including the code and database is copied to server, and the old ...
1 vote
1 answer
2k views

SSESS Cookie (Session ID) is being changed when loading images that don't exist

I have a Drupal 8.6.10 site which has a very confusing logout bug: I have a page that has various elements on it as images, js, css and so on. I load that page and everything works fine I add an ...
10 votes
5 answers
5k views

Why are my $messages delayed one page refresh?

I have a page with a very simple template: <!DOCTYPE html> <html> <head><title>TEST REGISTRATION PAGE</title></head> <body> <?php print ...
1 vote
0 answers
369 views

Autologout on browser close [closed]

I need to log out users when the browser session is closed and users are visiting a Drupal 7 site. I tried to modify the lines on the settings.php which calls ini_set() for session values, but it ...
1 vote
1 answer
361 views

Token Replacement via Lazy_builder

I've spent the best part of the last day or two trying to implement lazy_builder (as seen in this brilliant tutorial https://github.com/joachim-n/drupalcon-europe-2020-lazy-builders). However, rather ...
0 votes
3 answers
3k views

How do I display username in a custom block?

Am new to Drupal so this is a very fundemental question. How do I display the current username ? In a custom Block? I beleive is the $user->name session variable. Do I create a Custom Block Type?...
3 votes
0 answers
666 views

Use Memcache for sessions only [closed]

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

How to gets analyts and generate visual reports from sessions?

I'm looking for a technique or approach to get data from user session logs and convert it to a some sort of visual style (bars/charts/whatever). We'd like to specifically have the users session "arcs"...
0 votes
1 answer
85 views

Callback to Drupal site after curl call to 3rd party site doesn't resume authenticated session if more than 120 seconds elapsed since authentication

UPDATED SITUATION: A user authenticates on my site. The user selects items to purchase and is sent via curl call (see below) to a payment site. The payment site does its thing and returns to my site ...
14 votes
2 answers
34k views

How to set and retrieve cookies?

After several days and more hours I only found issues and patches about what to do once a cookie is set, but not one is mentioning how you get a cookie set in the first place. Our intention would be ...
2 votes
0 answers
277 views

Session variable and cache drupal [closed]

I've created a small helper where I can set and access my session variable (thanks to the drupal 8 session). Can't figure out why, my session is working well with my dev (no cache) but on my prod my ...
2 votes
1 answer
197 views

Using an authentication provider to keep a user permanently logged in eventually causes session problems

Because I got fed up of having to log in to my local development sites every however long, I tried making a simple custom module that just has an Authentication Provider service that always returns ...
-1 votes
1 answer
1k views

Get a session value in a template file

I am trying to get value set in session in a template file, but I don't get the expected value. I tried two methods, but neither of them works for me. The code in the custom module controller is the ...
1 vote
2 answers
4k 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 ...
1 vote
1 answer
114 views

Why are there entries in sessions table for uid 0?

I was alarmed to find sessions being written to the table [sessions] for uid 0. Do I need to worry or is this normal? I could not find answers by searching. I don't know how the sessions table works. ...
0 votes
0 answers
67 views

Set and read data in session between anonymous and authenticated user [duplicate]

On my Drupal 8 site, when an anonymous user "A" visit this link: https://www.example.com/page-1?data=12345678, I want to store the data value in a session and save it later to the user account under ...
1 vote
1 answer
1k 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
2 answers
2k views

Why 'Failed to start the session' when RedirectResponse is sent?

When this code is executed, I have an error message logged. The code is in shared_node_access(NodeInterface $node, $op, AccountInterface $account) if ($node->get('nid')->value == 1) { if ($...
-2 votes
2 answers
342 views

Incorrect handling of PHP sessions causes many 503 errors?

I use my personal website to host several images galleries, and for several months now, I've noticed that a lot of the thumbnail images appear broken and aren't loaded by the browser. This seems to be ...
0 votes
0 answers
214 views

SESSxxxxx cookie gets removed, $_SESSION data being lost but only locally

I have just pulled deployed code down to my local setup, restarted MAMP, cleared the Drush cache, and started a process that relies on data stored in $_SESSION. We can confirm this works in prod - no ...
0 votes
1 answer
103 views

How do I troubleshoot PrivateTempStore for session data?

I am updated one of my Drupal 7 modules for Drupal 8 and I discovered that I need to use PrivateTempStore rather than $_SESSION variables. I followed some great examples online, but it does not seem ...
2 votes
1 answer
428 views

How to bootstrap a custom script and retrieve the session object?

I'm writing a custom script that requires a proper Drupal 8 user session to work. This is the current version: <?php use Drupal\Core\DrupalKernel; use Symfony\Component\HttpFoundation\Request; $...

1
2 3 4 5