session error: login problems

session error: login problems

by m bossers -
Number of replies: 5
Hi all,

I tried to find the answer to my question on this site, but came across many different ideas on how to solve it.
I would like some one to help me on my particular case:

The problem:
1. If I take too long editing a course (let's say a few minutes or so), as an administrator: moodle throws me out and tells me to log in again. However; when I try to do that I get the message:
A server error that affects your login session was detected. Please login again or restart your browser.
2. Students who have logged out and want to log back in also get this message.

The -socalled- solution:
1. If you throw away your cookies, restart your browser, then you can log back in again.

My case:
I'm running moodle 1.7
It's on a shared server (by Lycos)
PHP 4.3.10 + 5.2.3
I use the option: Database for sessions.

Please help me !

thanks in advance.
Average of ratings: -
In reply to m bossers

Re: session error: login problems

by Richard Enison -
MB,

I've just finished researching this issue.
  1. Your "socalled solution" is only one of several that keep coming up in forum posts. Those who try it usually say it works for a while but then the problem starts happening again.
  2. If you went to the FAQ on this error, and followed the link to the forum thread on it, you will find other solutions, chief among which is one that seems to work when this problem occurs because you have more than one Moodle site on the same server. That is to make sure you use different cookie prefixes and/or different cookie paths for the different Moodle sites.
  3. You will also find that this problem has come up several times in the past with your host (Lycos). The claim is that they solved it, though they never answered the question of how. Apparently they haven't permanently solved it, since you are now experiencing it.
  4. Another solution is to make sure that config.php (in the main Moodle folder (directory)) does not have any white space before the opening <?php or after the closing ?>.
  5. Another solution involves changing folder permissions, or deleting the contents of the sessions folder.
  6. Another is to enable database session handling (instead of a sessions folder).
  7. Another is to make sure a Moodle site is not accessed by two different URLs (e.g. http://www.yourdomain.edu and http://yourdomain.edu).
  8. A solution suggested in MDL-3436 is to increase the time before sessions time out by setting $CFG->sessiontimeout to a high number (I don't know offhand what unit it is measured in or what the default currently is). [EDIT: I just checked the database in my Moodle site and the value is 7200. Which means the unit is probably seconds, and the value is two hours.] See also MDL-14263, 14244, 14245, 4504, 6327, 3395, and http://moodle.org/mod/forum/discuss.php?d=49419#p235434.
  9. So if all the solutions you find in the thread, and in any links contained in it, and the above, fail for you, there is one that I think will absolutely work, because it bypasses the session test that triggers the error msg. I checked the code and am virtually certain of that. Unfortunately, it will make your site less secure, so it is a last resort. Here it is: cookieless sessions.
RLE
In reply to Richard Enison

Re: session error: login problems

by m bossers -
Hi RLE,

Thanks for your help.

@2: I use a special cookie prefix and path
@4: config.php doesn't have any white space
@5: folder permissions set at 775, looks fine
@6: we tried database handling, however some people on this site tell you not to do that on a shared server. What gives ?
@7: we have only one domain.
@8: where can i find $CFG->sessiontimeout ? Is that in config.php ?
@9: Will try that !

Thanks,

Maurice.
In reply to m bossers

Re: session error: login problems

by Richard Enison -
MB,

6. Is it not your database and your web site? True, using dbsessions is less efficient, but isn't it your money being wasted on it? If I want to have my lights on in my apartment all the time, as long as I'm buying the bulbs and paying the electric bill, that's not my landlord's business! However, it is recommended that dbsessions only be used temporarily until the real cause of the problem is determined, for that reason. See http://docs.moodle.org/en/Installation_FAQ#I_can.27t_log_in_with_message_.22Please_verify_that_the_current_setting_of_session.save_path_is_correct.22.

7. In the example I gave, both URL's used the same domain name.

8. It can be, but only if someone puts it there. By default it is set to 7200 in admin/settings/server.php using the admin_setting_configselect function.

RLE
In reply to Richard Enison

Re: session error: login problems

by m bossers -
Hi Richard,

Thanks again for your help.

Few more questions.

1)I'm having a go at cookieless sessions. Seems to work fine, as long as your browser doesn't accept cookies. If it does; moodle switches back to cookie-usage. Is there any way to prevent this ?

2)As I mentioned, I use sessionsdbase. However; the sessions don't appear in my folder /moodledata/sessions. I've set the path to that folder, but nothing seems to happen. Any ideas ?

Thanks in advance !


Maurice.
In reply to m bossers

Re: session error: login problems

by Richard Enison -
MB,
  1. According to Cookieless Sessions:

    "Enable cookieless sessions by including $CFG->usesid=true; in config.php."

    Did you do that? If not, please read the rest of the doc page. There are other suggestions you might profit from.
  2. By sessionsdbase I presume you mean dbsessions. If you are using that option it means the sessions will be stored in your database, not in the sessions folder, as I mentioned in a previous post. So it is doing exactly what it is supposed to. Do you want it to do that or not? If not, stop using dbsessions.
RLE