<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://docs.moodle.org/400/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Stevenf</id>
	<title>MoodleDocs - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://docs.moodle.org/400/en/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Stevenf"/>
	<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/Special:Contributions/Stevenf"/>
	<updated>2026-04-22T23:18:00Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://docs.moodle.org/400/en/index.php?title=Sessions_FAQ&amp;diff=117626</id>
		<title>Sessions FAQ</title>
		<link rel="alternate" type="text/html" href="https://docs.moodle.org/400/en/index.php?title=Sessions_FAQ&amp;diff=117626"/>
		<updated>2015-03-20T05:32:54Z</updated>

		<summary type="html">&lt;p&gt;Stevenf: Very minor spelling correction: &amp;#039;There&amp;#039;s&amp;#039; refers to a singular way to do something, whereas &amp;#039;There are&amp;#039; refers to various ways to do something.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Managing a Moodle site}}&lt;br /&gt;
== What is the purpose of Sessions? ==&lt;br /&gt;
Web applications are &amp;quot;stateless&amp;quot;. That is, by nature, any information stored in program variables is lost each time a script completes. That happens on every page. So for anything other than completely trivial scripts you need to have a way of storing information for that user for the current login. There are various ways to do this but the simplest is an implementation of PHP&#039;s native $_SESSION[] array that will keep information for a particular user on the same PC for a short period of time.&lt;br /&gt;
&lt;br /&gt;
== What information do they hold?==&lt;br /&gt;
Sessions hold a range of information. The fact that you are logged on, your user profile, etc. Anything that needs to be available on all Moodle pages quickly.&lt;br /&gt;
&lt;br /&gt;
== How are they constructed? ==&lt;br /&gt;
It&#039;s a PHP thing. It&#039;s very simple. Moodle issues the session_start() &#039;command&#039; and then access PHP&#039;s $_SESSION variable. The contents of that automagically persist in a written file/database/memcached server.&lt;br /&gt;
&lt;br /&gt;
== How long should they be retained for? ==&lt;br /&gt;
There is no reason to keep them beyond the current, well, session. &lt;br /&gt;
&lt;br /&gt;
== Do I need to include them in my site backups? == &lt;br /&gt;
No, not at all. The information required is for the immediate purposes of Moodle and is not required beyond that. &lt;br /&gt;
&lt;br /&gt;
== Do I need to delete them? ==&lt;br /&gt;
&lt;br /&gt;
Session files should automatically be deleted when they are no longer needed. If files are building up you should look into why.&lt;br /&gt;
&lt;br /&gt;
=== How do I delete them? ===&lt;br /&gt;
It&#039;s not very elegant, but at quiet times you can simply delete the sessions directory in moodledata. The worst that will happen is that anyone logged in gets thrown off. A slightly more elegant solution would delete any files in that directory more than a few hours old.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
*[[Session handling]]&lt;br /&gt;
&lt;br /&gt;
[[Category:FAQ]]&lt;br /&gt;
&lt;br /&gt;
[[de:Sitzungen FAQ]]&lt;/div&gt;</summary>
		<author><name>Stevenf</name></author>
	</entry>
</feed>