Welcome, Guest
Username: Password: Remember me

TOPIC: Accessing $_SESSION outside of LS Admin directory

Accessing $_SESSION outside of LS Admin directory 2 years 6 months ago #78255

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
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
The administrator has disabled public write access.

Re: Accessing $_SESSION outside of LS Admin directory 2 years 6 months ago #78406

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
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
The administrator has disabled public write access.

Re: Accessing $_SESSION outside of LS Admin directory 2 years 6 months ago #78409

  • tacman1123
  • tacman1123's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 125
  • Karma: 1
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.
The administrator has disabled public write access.

Re: Accessing $_SESSION outside of LS Admin directory 2 years 6 months ago #78412

  • DenisChenu
  • DenisChenu's Avatar
  • OFFLINE
  • Moderator Lime
  • Posts: 6451
  • Thank you received: 844
  • Karma: 249
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.
Last Edit: 2 years 6 months ago by DenisChenu. Reason: Some var name
The administrator has disabled public write access.

Re: Accessing $_SESSION outside of LS Admin directory 2 years 6 months ago #78667

  • Mazi
  • Mazi's Avatar
  • OFFLINE
  • LimeSurvey Team
  • Posts: 5333
  • Thank you received: 296
  • Karma: 249
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)limesurvey.org'"
The administrator has disabled public write access.
Moderators: ITEd
Time to create page: 0.200 seconds
Donation Image