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
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
20 votes
6 answers
25k 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', $...
Kevin's user avatar
  • 2,558
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
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
0 votes
1 answer
391 views

How to reset/save $_SESSION variables in forms for each user?

I need to add captcha to user login form after 3 failed logins. To do so I built the following module, and used $_SESSION['failed_login'] to keep track of the number of the failed logins. This ...
M a m a D's user avatar
  • 3,862
1 vote
1 answer
60 views

Odd $_SESSION contents

I have a page in Drupal from which I want to be able to read the $_SESSION data to determine the userid and their assigned role. As an exploration I attempted to print to the page the contents of $...
AdamJS's user avatar
  • 13
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
0 votes
2 answers
157 views

Is it okay to store a $node object as a $_SESSION variable

My contrib module currently stores a $node object temporarily in the variable table, and stores the nid for that $node in the $_SESSION variable so that the $node can be retrieved from the variable ...
Jim's user avatar
  • 833
0 votes
1 answer
66 views

Check, anywhere during a session, if a logged in user has previously logged in

There are a number of properties on the global $user object https://api.drupal.org/api/drupal/developer%21globals.php/global/user/7 But I can't figure out how to see if a logged in user has ever ...
commonpike's user avatar
8 votes
3 answers
406 views

How can I programatically log another user out in D7?

On our site we have client accounts, each with a super administrator and sub users belonging to that account. We want the super admin to be able to force sub users to log out. What's the best way to ...
BrianV's user avatar
  • 638
1 vote
1 answer
867 views

How to store information in session for anonymous user in a site without a user with uid=0?

In our system for some reason, we have deleted user with 0 uid. But for now I have to store some information in session for anonymous users. But Drupal is not allowing me to save the information in ...
Abuzer Firdousi's user avatar
3 votes
2 answers
223 views

Problem with anonymous Flag and webform_select_ options_info() only visible to logged in users

So I've been trying to implement an anonymous "wish list" for an eCommerce site using webform_select_options and Flag. My implementation uses an anonymous flag set on my products and uses ...
nizz0k's user avatar
  • 1,172
0 votes
1 answer
1k views

Is it acceptable solution to set session.gc_maxlifetime in hook_init()?

We need to set session.gc_maxlifetime separately on the site and mobile (app). Is any best practices here? UPD. My final solution looks as follows: $args = arg(); $is_mob_rest_api = FALSE; if (!...
graceman9's user avatar
  • 662
1 vote
1 answer
2k views

Why does Drupal have both "sid" and "ssid" field in the session?

Learning more about Drupal core so I can be a better contributor, understand security better, etc. I noticed that on creating a session Drupal uses both an "sid" and "ssid" field. The code seems to ...
danielson317's user avatar
0 votes
0 answers
25 views

How to get session user id in custome php file [duplicate]

I want user session id in my custom ajax file named "ajax_page.php" below is code that i have placed in that file but i am not able to get object array of $user that i'hv defined as Global $user. ...
Krunal Hingu's user avatar
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 ...
Markus Sipilä's user avatar
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
0 votes
1 answer
31 views

Can't visit site after switching on Language Detection 'Session' in combination with Ip to locale [closed]

My site is in a kind of a loop? I can't login anymore and visit the site? http://landberg.at/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/nl/en/user What do i have to do. Its a ...
Meez's user avatar
  • 149
1 vote
1 answer
101 views

Assigning global var to session variable? [closed]

I want to assign the user name to a SESSION variable, yet this is not working. $_SESSION['loveleytest'] = $user; $_SESSION['thelovelytest2'] = $user->name; What should I do?
Baybook's user avatar
  • 301
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 ...
Krishna Mohan'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
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
3 votes
5 answers
2k views

How to keep the size of the database reduced?

I found out a very simple D7 site with less than 150 nodes had database dumps of 65M (gzipped). Which caused my entire server to become slow during the nightly database dumps. After some searching I ...
the's user avatar
  • 1,704
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 ...
Key's user avatar
  • 304
0 votes
1 answer
58 views

How to create a list of nodes that the anonymous user has created and limit it by the current session (SID)?

Is there a way to create a list of nodes that the anonymous user has created and limit it only by the user's current session? Basically I want the anonymous user to create a node under a specific ...
Joshua Abellare'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
1 answer
3k views

Unable to log in due to session cookies not being passed in

I have an html5 app which logs the user into drupal via services 3.11 but I am unable to connect. Using the Chrome Postman plugin I can connect as expected. The difference between Postman and my code ...
nakeddesign's user avatar
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
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
0 votes
1 answer
61 views

What function or $user variable do I edit to manually increase a user's session timeout?

I'm using the simpleSAMLphp module which redirects the user offsite to login and then hits them back to drupal in a logged in state, but for some reason the sessions aren't getting applied. When the ...
Patoshi パトシ's user avatar
1 vote
1 answer
726 views

How do I edit the response of successful register.json?

How can you edit the Services' json response of successful register.json to include the user's OR system's auto-generated password, plus any token? I've tried a variety of combinations of the ...
E.A.T's user avatar
  • 374
9 votes
2 answers
1k views

register.json does not login the user or return the user's session/token/password

I have tried far too many variations to list here, but the basic point is I cannot get the user logged in immediately after registration via Services. I have tried a fresh Drupal 7.33 install with ...
E.A.T's user avatar
  • 374
0 votes
2 answers
4k views

Services 3 Session authentication CSRF Validation with Persistent Log in

I am trying to use Services 7.x-3.11, the latest stable available to authenticate and access Drupal 7.34. Accessing from mobile devices with Native coding. I want to keep the user authenticated ...
niksmac's user avatar
  • 7,682
2 votes
1 answer
648 views

What is the best way to tell anonymous users apart?

My company wishes to split their website so that anonymous users are given slightly different sites based on a question when they first visit. I intend to use a cookie to store the answer to the ...
Darvanen's user avatar
  • 4,073
0 votes
1 answer
225 views

Unable to return session value in views Field

I am storing a session value via Rules when the user is logged in session_start() $_SESSION['userkey'] = "12345"; Also testing it below there echo $_SESSION['userkey']; Although when I am trying ...
pal4life's user avatar
  • 554
1 vote
2 answers
875 views

Access denied error after login

When i log in to drupal doesn't matter with any account either admin or normal user. I get error Access Denied. I then again try to login and it works fine. What is that problem? My theme was shipped ...
user avatar
0 votes
0 answers
106 views

Simpletest: working with sessions and custom function

I need to add a simpletest case to my custom module. Module functionality: The module has a function to store data on $_SESSION, on the next page load if $_SESSION has a custom value a javascript ...
jorgetutor's user avatar
  • 2,125
2 votes
1 answer
193 views

How do I get a hold of the session object in my form handler?

I have build a form in D8 and on submit I want to save the form values into a session, so that I can access them 3, 4,.... page requests later. In D7 I just used $_SESSION['key'] = $value I have a ...
Robin's user avatar
  • 2,021
14 votes
7 answers
23k views

How do I store the values submitted in a form in the session?

I want to submit a form and store the submitted values in the session. In Drupal 7 I just used $_SESSION['key'] = $value; but how do I correctly implement this in Drupal 8?
Robin's user avatar
  • 2,021
0 votes
1 answer
624 views

How to set different logout times for roles?

I would like to define/set a log out time for different roles for my Drupal site. Say for example if I set log out time for X role for 30 Minutes. The users under that role would be logged out in 30 ...
Krishna Mohan's user avatar
0 votes
1 answer
196 views

Users logouts from time to time

I only want users to logout if they visit the "logout" page. For this I set this in my settings file: ini_set('session.gc_maxlifetime', 0); ini_set('session.cookie_lifetime', 0); But users are still ...
FriOne's user avatar
  • 364
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 ...
hkoosha's user avatar
  • 994
1 vote
1 answer
2k views

Sessions / Cookies not working for user login, registration or shopping cart

The Problem One of our sites has recently broken. Users can't login or register, and the shopping cart isn't working either. Drupal does not display any errors. Upon clicking the submit button for ...
Paul Kerrigan's user avatar
0 votes
0 answers
176 views

Why would error / warning / success messages stack up when using a Service?

I have a mobile app that uses Drupal as an API. As you navigate the site everything works as normal with appropriate messages on errors, warnings, and successful form submissions. After doing that a ...
E.A.T's user avatar
  • 374
1 vote
2 answers
3k views

Anonymous User gets cookie

I recently saw that when I open of my sites as a anonymous user, a session cookie is set. I checked the database sessions table, and there is a line for uid 0 as well. How can I prevent drupal from ...
Sebastian's user avatar
  • 635
0 votes
0 answers
576 views

Forms - Multiple Checkboxes Default Values Not Populating

I have a Drupal 7 form using multiple checkboxes. The default value is based on a session variable. However, if I uncheck all of the boxes, I still have a default session variable but it is not ...
John's user avatar
  • 215
2 votes
1 answer
4k views

Use Redis for Drupal sessions

I've been looking online for a while and I haven't seen anything on setting up Drupal to use Redis for session handling. I've found tutorials and blogs about settings Redis up as a replacement for ...
FatGuyLaughing's user avatar
3 votes
1 answer
1k views

How to preserve form values for user who navigates out of form and back?

I have a form that works, essentially, as a search / filter: foreach($search_properties as $property) { $form['properties'][$property->idProperty] = array( '#title' => $property->...
Mołot's user avatar
  • 21.9k
0 votes
1 answer
198 views

user not logged in php file

I want use drupal functions in php files,I did it with below code $path = $_SERVER['DOCUMENT_ROOT']; chdir($path); define('DRUPAL_ROOT', getcwd()); //the most important line require_once './includes/...
Yuseferi's user avatar
  • 21.8k
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