Moodle destroys my sessions - make it stop

Moodle destroys my sessions - make it stop

by Rasmus Kongshøj -
Number of replies: 3

I'm currently developing a new Moodle portal that has to integrate with an already existing web site. I thought I could just use PHP's $_SESSION variable to pass data from the other system to Moodle but it seems like Moodle resets my session variable.


How can I prevent Moodle from doing this?


What would be the correct way to pass session data to Moodle?

Average of ratings: -
In reply to Rasmus Kongshøj

Re: Moodle destroys my sessions - make it stop

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Moodle initialises and makes use of the PHP $_SESSION variable itself, so, unless you are wanting to rewrite many major parts of Moodle, you should not be touching $_SESSION at all.

Moodle does have a variable called $SESSION, which it uses to store session data. You may have some success with including the Moodle config.php file, then adding values to $SESSION, if you want to pass them on to other code you have running within Moodle itself.


Average of ratings: Useful (1)
In reply to Rasmus Kongshøj

Re: Moodle destroys my sessions - make it stop

by Rasmus Kongshøj -

Thank you very much for the replies. You have been most helpful smile