Questions tagged [sessions]
Use it for questions about the session system, which handles recognizing users from a session cookie.
234
questions
-1
votes
2
answers
202
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
3
answers
1k
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 ...
5
votes
2
answers
4k
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
1
answer
78
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
2
answers
102
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
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()...
0
votes
1
answer
198
views
How to write session data for another user? [closed]
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 ...
3
votes
0
answers
653
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
1
answer
2k
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
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 ...
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 ...
2
votes
2
answers
309
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
2
answers
109
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 ...
3
votes
2
answers
2k
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
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 ...
-1
votes
1
answer
2k
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
1
answer
2k
views
How to secure session cookies [closed]
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 ...
3
votes
1
answer
999
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
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, ...
0
votes
2
answers
584
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
1
answer
577
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 ...
2
votes
1
answer
443
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 ...
5
votes
1
answer
2k
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 ...
3
votes
1
answer
284
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
1
answer
66
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
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 ...
5
votes
1
answer
2k
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 ...
4
votes
2
answers
2k
views
How does the Drupal session system work?
I would like to implement the familiar "Remember me" functionality on user login forms, i.e. if a registered user leaves the browser without hitting the log out link, (s)he will still be logged in ...
0
votes
1
answer
799
views
drupal_set_message for anonymous user
I am having hard time displaying drupal message for anonymous users. My scenario is, I need to display message if there is certain query string and remove the query string with message. I am using ...
0
votes
2
answers
104
views
Make my session non persistent
I created a function to save the location (city, lat, long) of the user. So when he change the page, I don't need to convert his location again. So I've a problem. The session might be saved because ...
2
votes
1
answer
6k
views
How do I delete cookies when users log out?
How do I delete cookies when users log out? How can I do this with out modifying any core module?
1
vote
2
answers
3k
views
Why do templates never update dynamic variables after cached?
Given my twig extension:
use \Symfony\Component\HttpFoundation\Session\Session;
class RainbirdTwigExtension extends \Twig_Extension {
public function getGlobals() {
$session = new Session()...
4
votes
1
answer
2k
views
Php Access User Data from external script
Currently my Drupal installation is at www.example.com/wiki/
I was wondering if it is possible in Drupal 8.2.4 to access the current user uid from an external php script.
The script is located at ...
0
votes
1
answer
2k
views
How do I clean up the sessions table?
I need to delete entries about anonymous user login from the sessions table.
I read what reported in
https://techcommons.stanford.edu/topics/drupal/sessions-table-cleanup.
Which PHP setting in the ...
0
votes
1
answer
2k
views
Session variable lost after setting it in ajax call
In my custom .js code included into administration panel via my custom module I have AJAX call:
... //call this on click or sth
jQuery.post("sites/all/...mycustommodule/ajax/here.php", function(...
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, ...
0
votes
1
answer
2k
views
Cannot start session for anonymous user
I'm trying to start a session for anonymous users (using Drupal 8.2.2), so I can use the private temp store, but the session does not persist. This is what happens with anon users:
// $session is the ...
1
vote
2
answers
102
views
Is it safe to use $_SESSION to store temporarily a user provided value under multi-step form processing
I have a form which contains an AJAX button press callback. Upon pressing this AJAX button, I want to store temporarily a form element's value before fully processing all the data upon pressing main ...
1
vote
2
answers
26
views
what are the different ways to use the variable in many functions within a module?
I want to access a variable changed in one function in another. I tried this with Session and global variables. I need the variable to be persisted across multiple page requests. are there any other ...
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 ...
4
votes
2
answers
714
views
How to prevent multiple logins for administrator?
I have my Drupal website whose admin account is shared. But I want to limit the multiple logins, that is, only one should be able to login at a time. I have already used Session Limit Module. This ...
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
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 ...
0
votes
1
answer
1k
views
Login Users sessions persistence using Services and Rest Server modules
I'm having a heck of a time creating drupal services from angular hitting the rest server. I created a rest end point for all my authentication needs, configured in the Service module. When I use ...
0
votes
1
answer
373
views
Add custom value in session
How can I add value in drupal session. I am adding value using $_SESSION = 'my value', but once trying to print $_SESSION variable it return blank.
-1
votes
1
answer
91
views
What session are better to use? [closed]
i already tried the private tempstorage class on local it is working. but when i put it on cloud it was not working anymore.
use Drupal\user\PrivateTempStoreFactory;
$session = \Drupal::service('...
-1
votes
2
answers
2k
views
How to close and start sessions? [closed]
How do i port following D7 code to D8?
drupal_save_session(FALSE);
session_write_close();
drupal_save_session(TRUE);
ini_set('session.cookie_lifetime', $cookie_lifetime);
...
2
votes
0
answers
339
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 ...
3
votes
1
answer
880
views
Difference between browser session and Drupal session
After reading this question over here from 2014, I'm left wondering:
Is there any benefit, security concern, or real reason to use Drupal's session manager class over the browser session $_SESSION[...
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 ...