Check out the LimeSurvey source code on GitHub!

Accessing $_SESSION outside of LS Admin directory

More
4 years 10 months ago #78255 by tacman1123
I'm trying to access the $_SESSION array from a report script I'm working on. Because it's in a separate directory (for source control management), I'm not able to see the $_SESSION information about login.

I've changed sessioncontrol.php to use a global path:
// session_set_cookie_params(0,$relativeurl.'/');
session_set_cookie_params(0,'/'); // tac: needs session info across domain

Logged out and logged back in, but I don't see the $_SESSION from my script, so it's failing when I try to get the list of surveys.

What script / function needs to be called to set the session?

Thx,

Tac

Please Log in to join the conversation.

More
4 years 10 months ago #78406 by DenisChenu
Hello,

Maybe the session_name and look for the session_save_path in htaccess/virtual host.

For session name: look at admin/sessioncontrol.php

And for session_save_path:
php.net/manual/function.session-save-path.php
(or best, directly) php.net/manual/session.configuration.php#ini.session.save-path

If http server are set for the same user, you can use directly: "/tmp", or "/home/$USER/session" and then no problem for accessing the same session var.

Denis

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).

Please Log in to join the conversation.

More
4 years 10 months ago #78409 by tacman1123
It turned out to be that the framework I was using had its own session handling, and the two were conflicting. I haven't really figured out a way around it, except to disable the framework sessions. Otherwise, it will throw an error when the second session_start() is called. I guess what I really want is a way to start one session, grab the data, stop that session, start a new session, and import the data from the first session. But not sure that session_destroy will work for that.

Please Log in to join the conversation.

More
4 years 10 months ago - 4 years 10 months ago #78412 by DenisChenu
With a framework, maybe it's more difficult, but witn a php file:
session_name($LS_session);
session_start();
$ls_session_data = $_SESSION;
session_write_close();
 
session_name($Your_session);
session_start();
session_regenerate_id();
 
$_SESSION['ls_data'] = $ls_session_data;
And then you can acces to the LimeSurvey admin session with $_SESSION or other session data.

Denis
PS: i never verify the code i put in forum, error are possible.

Assistance on LimeSurvey forum and LimeSurvey core development are on my free time.
I'm not a LimeSurvey GmbH member, professional service on demand (or search sondages pro).
Last Edit: 4 years 10 months ago by DenisChenu. Reason: Some var name

Please Log in to join the conversation.

More
4 years 10 months ago #78667 by Mazi
Tac, which framework do you use?


Best regards/Beste Grüße,
Dr. Marcel Minke
(Limesurvey Head of Support)
Need Help? We offer professional Limesurvey support
Contact: marcel.minke(at)survey-consulting.com'"

Please Log in to join the conversation.

Imprint                   Privacy policy         General Terms & Conditions         Revocation information and revocation form