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
2
votes
3answers
139 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. ...
2
votes
2answers
11k 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('...
0
votes
1answer
356 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 ...
1
vote
1answer
50 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 $...
1
vote
0answers
41 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 ...
0
votes
2answers
150 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 ...
0
votes
1answer
64 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 ...
8
votes
3answers
346 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 ...
1
vote
1answer
787 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 ...
3
votes
2answers
208 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 ...
0
votes
1answer
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 (!...
1
vote
1answer
1k 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 ...
0
votes
0answers
24 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. ...
7
votes
3answers
5k 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
1answer
183 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, ...
0
votes
1answer
29 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 ...
1
vote
1answer
100 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?
0
votes
1answer
927 views

How to know Active sessions in Drupal?

Is there any way to find my opened/active sessions and close them in Drupal?. Like in Gmail, If there already exists a session for the logged in user they can be notified like the follows and they can ...
2
votes
1answer
324 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 ...
1
vote
0answers
91 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 ...
3
votes
5answers
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 ...
0
votes
3answers
937 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 ...
0
votes
1answer
56 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 ...
1
vote
0answers
321 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 ...
1
vote
1answer
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 ...
1
vote
0answers
130 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 ...
2
votes
1answer
110 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. ...
0
votes
1answer
55 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 ...
1
vote
1answer
696 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 ...
9
votes
2answers
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 ...
0
votes
2answers
3k 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 ...
2
votes
1answer
596 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 ...
0
votes
1answer
221 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 ...
0
votes
2answers
845 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 ...
0
votes
0answers
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 ...
2
votes
1answer
191 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 ...
11
votes
8answers
19k 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?
0
votes
1answer
507 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 ...
0
votes
1answer
140 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 ...
7
votes
2answers
8k 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
1answer
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 ...
0
votes
0answers
175 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 ...
1
vote
2answers
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 ...
0
votes
0answers
574 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 ...
2
votes
1answer
3k 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 ...
3
votes
1answer
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->...
0
votes
1answer
191 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/...
1
vote
0answers
212 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 ...
6
votes
2answers
11k views

How to get an anonymous user session id?

I am writing a chat module where anonymous users are able to chat with a logged in user via an external websockets connection. I need an ID to uniquely distinguish the anonymous users and assign them ...
2
votes
1answer
414 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 "...