Questions tagged [sessions]

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

64 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
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 ...
andrewjm's user avatar
3 votes
1 answer
527 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 ...
Sean Robertson's user avatar
3 votes
1 answer
1k 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 ...
user avatar
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']),...
ana's user avatar
  • 143
3 votes
0 answers
838 views

Cookie-less authentication with session ID

I'm building decoupled drupal site. I need to be able to authenticate REST client via session ID passed in a URL (or maybe custom header) instead of a cookie. At first I thought about implementing my ...
SiliconMind's user avatar
  • 3,151
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 ...
Joe Micallef's user avatar
2 votes
1 answer
149 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 ...
joachim's user avatar
  • 846
2 votes
0 answers
337 views

ADFS integration - user session creation without the user creation

I did not find my answer after reading some articles. For the user authentication, my Drupal site needs to communicate with a SAML IdP (ADFS). I have an additional requirement: The user must be ...
Jiraya's user avatar
  • 31
2 votes
3 answers
181 views

Session is not getting maintain in settings.php drupal 7

I have Created one php file on root of drupal7 and access it using URL.I have one form in that file which has dropdown values and submit button. Now in settings.php i am getting those value in POST. ...
Nikhil Valand's user avatar
2 votes
1 answer
328 views

Anonymous sessions breaking login for Drupal 7

This is my first official post so bare with me if i do not have all the information you may need. Being a beginner of Drupal from a PHP background I am struggling with SESSIONS. First, there are ...
colin's user avatar
  • 21
2 votes
1 answer
112 views

Access control based on session

Currently I am making a website for restaurants. In the site, each restaurant is a node type and a menu item is another node type. The relationship between restaurant and menu items is one to many. ...
user3110099's user avatar
2 votes
1 answer
519 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....
Jon Paul Vivere's user avatar
2 votes
0 answers
1k views

Storing variables in sessions not working

Here is my Custom code I am placing in views custom php field, Strange enough the variables are not storing in sessions except the last session variable, this is strange. drupal_session_start(); $...
Flash Alexander's user avatar
2 votes
2 answers
12k 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('...
Debbz's user avatar
  • 51
2 votes
2 answers
113 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 ...
Pawan Saxena's user avatar
1 vote
0 answers
702 views

cant read current user in middleware

i am relatively new to drupal . thus i am trying to make an sso system work . i have this parent domain "domain.com" and the drupal site is running on sub.domain.com  . i can read the cookies and all ....
akramabdelrahman's user avatar
1 vote
0 answers
187 views

Is it possible to provide a temporary role to an anonymous session?

Use-case is to provide a set of permissions to an "anonymous" user i.e. we don't know who they are and they haven't logged in, we just have their IP range to confirm where they're coming from (yes I ...
Eli Lisseck's user avatar
1 vote
0 answers
71 views

update all active sessions with custom data stored in the database sessions

Every user stores the session-data in the database (xxx_sessions). The tricky thing here is a custom data stored in the session with $_SESSION['CURRENT_DOC_YEAR'] = $current_doc_year;. This session ...
Criss's user avatar
  • 11
1 vote
0 answers
312 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 ...
DavSev's user avatar
  • 153
1 vote
0 answers
544 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 ...
Justin Levi Winter's user avatar
1 vote
0 answers
506 views

Session expires for user logged in by moblie app

I am using drupal 7 services module version 3.x. I do not want my session to be expired. I have set ini_set('session.gc_maxlifetime', 946080000); and ini_set('session.cookie_lifetime', 0); This is ...
Anamika's user avatar
  • 145
1 vote
0 answers
51 views

Persist session variables from drupal site to another domain

I have a drupal 7 website mydrupal7.com. Authenticated users can complete questionnaires and request reports based on their questionnaires. The questionnaire data is given a unique id which is linked ...
dantic's user avatar
  • 11
1 vote
0 answers
94 views

Session gets lost when a user closes their browser

When user login, I am creating cookie till a certain date. When the browser tab is closed while the user is logged in, the session remains. But when we quit the browser, the session is lost and user ...
Sirish Ayyagari's user avatar
1 vote
0 answers
323 views

Problem getting Drupal SESSION value from standalone php page in subdirectory

Last 2 days I am searching for solution on Internet. I have a module in my drupal site's "sites/all/modules" folder named "coupon".I added a new test.php file in the "coupon" folder which has no ...
SuUbha's user avatar
  • 11
1 vote
0 answers
134 views

Lost Sessions on Drupal Commerce Checkout

Recently we have been experiencing Page Not Found errors during the checkout process of our Drupal Commerce site. The problem seems to occur when a customer travels from the checkout page to the ...
PaulJ's user avatar
  • 41
1 vote
0 answers
213 views

How to exchange variable values between contextual filters of the same view?

I have a view with two Global: NULL fields as contextual filters, which use php code in their default value. The first global null value calculates and provides an order quantity, and the second ...
Yuri's user avatar
  • 618
1 vote
0 answers
69 views

Why are there many session entries for anonymous users in my sessions table?

I checked the session table and it was getting huge. Most entries are the anonymous users. Does Drupal make sessions for anonymous users, or only on error pages?
awm's user avatar
  • 2,429
1 vote
0 answers
371 views

Is it possible to trace a Drupal PHP session variable and if so, how?

I'm having an issue with Drupal not caching pages and I think it's being caused by an active PHP session variable being set for anonymous users. I want to know if it's possible to quickly and/or ...
Jamie Hollern's user avatar
1 vote
0 answers
628 views

How can i control session limit module?

I am using Session Limit module for restrict user to login into site from multiple browsers at a time.But here i am facing a problem is if user close the browser with out logout,then the session will ...
Pradeep K's user avatar
0 votes
0 answers
38 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 ...
DevNooby's user avatar
0 votes
0 answers
161 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) { ...
lobafox's user avatar
  • 103
0 votes
1 answer
383 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 ...
Maarten Hartman's user avatar
0 votes
0 answers
76 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 ...
Mark Edwards's user avatar
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 ...
Miloš Kroulík's user avatar
0 votes
0 answers
141 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 ...
Vincent Buscarello's user avatar
0 votes
0 answers
175 views

How do change the value of a session before form submission

I created a custom module that allows users to enter their information, and during the form submission, I set a session with the name that they type in the form: $session = \Drupal::request()->...
Sidney Sousa's user avatar
0 votes
0 answers
72 views

How do I get rid of anonymous sessions?

In a Drupal 7 site taken over from an ex-colleague, sessions for anonymous user always are generated as this screenshot shows. The security-scanning service provider always claims: Our ...
Vincent's user avatar
0 votes
0 answers
28 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 ...
user1015214's user avatar
  • 1,801
0 votes
2 answers
1k 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 ...
i am batman's user avatar
0 votes
0 answers
266 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-...
atg963's user avatar
  • 53
0 votes
1 answer
951 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 ...
Thomas's user avatar
  • 101
0 votes
0 answers
320 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 ...
pperez42's user avatar
0 votes
0 answers
111 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()...
Janey's user avatar
  • 1,270
0 votes
1 answer
46 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 ...
Adaddinsane's user avatar
0 votes
1 answer
286 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, ...
Bibokid's user avatar
  • 325
0 votes
0 answers
48 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 ...
user avatar
0 votes
1 answer
49 views

How to restore $form_state when rebuilding a form after a redirect

We have a site where either authenticated or unauthenticated users can submit a form. When the form is validated, we check whether they are logged-in, and if not, we redirect them to authenticate, ...
Monkeybrain's user avatar
0 votes
0 answers
54 views

multidomain commerce with separate cart cookie/session for every domain

I have 3 domains pointing to same drupal instance (possible without domain access module). Setup: DomainA,DomainB,DomainC. Based on domains, the appropriate translated content is used. This is ...
loparr's user avatar
  • 916
0 votes
1 answer
2k 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 ...
ana's user avatar
  • 143
0 votes
1 answer
196 views

How to use 'session' to check path history of user

I want to keep a track of the pages user visited, I got to know i can do this with the help of session and hook_node_view. Being a beginner, i couldn't find any particular help on using session API, ...
Rakesh Verma's user avatar