Unable to log in (2.6)

Unable to log in (2.6)

by Patricia Loofbourrow -
Number of replies: 16

I am migrating my school to a new server and have had some issues. The main one is that I can't log in. My server has the correct requirements for my version of Moodle and am using Firefox 32.0 on Windows 7.

Debugging gave me the following:


Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home1/edibled1/public_html/studio/config.php:2) in /home1/edibled1/public_html/studio/lib/classes/session/handler.php on line 42

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home1/edibled1/public_html/studio/config.php:2) in /home1/edibled1/public_html/studio/lib/classes/session/handler.php on line 42

Warning: session_regenerate_id(): Cannot regenerate session id - headers already sent in /home1/edibled1/public_html/studio/lib/classes/session/manager.php on line 275


Any suggestions appreciated.


Average of ratings: -
In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Guillermo Madero -

Hello Patricia,

Please open your Moodle config.php configuration file and see that the file doesn't end with a "?>" (question mark, greater than) closing tag:

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
?>

Instead, it should end like this:

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!
In reply to Guillermo Madero

Re: Unable to log in (2.6)

by Patricia Loofbourrow -

The characters you mentioned were not in my config.php file.

In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I think Guillermo is on the right track all the same. There is probably something, someplace getting output that shouldn't be. It could be hard to find, but, as this shouldn't happen is there anything non-standard about your Moodle code? If in the slightest doubt, download a completely fresh copy of Moodle from moodle.org (nowhere else) and replace your existing code. Don't be tempted to add anything optional at this stage.

In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Guillermo Madero -

Hello Patricia,

Please:

1. Make a copy of your config.php file.

2. Open the copied file.

3. Star the sensitive information like this:

$CFG->dbname = '***';
$CFG->dbuser = '***';
$CFG->dbpass = '***';

4. Save the file and post it here.

Average of ratings: Useful (1)
In reply to Guillermo Madero

Re: Unable to log in (2.6)

by Patricia Loofbourrow -

Ok there's so many suggestions on this thread that I feel quite confused now as to what to actually do but I will do this one first.

There is no blank space or any other symbols before or after this code.

<?php  // Moodle configuration file
phpinfo();
unset($CFG);
global $CFG;
$CFG = new stdClass();

$CFG->dbtype    = 'mysqli';
$CFG->dblibrary = 'native';
$CFG->dbhost    = 'localhost';
$CFG->dbname    = '***';
$CFG->dbuser    = '***';
$CFG->dbpass    = '***';
$CFG->prefix    = 'jmn_';
$CFG->dboptions = array (
  'dbpersist' => 0,
  'dbport' => '',
  'dbsocket' => '',
);

$CFG->wwwroot   = 'http://studio.edible-landscape-design.com';
$CFG->dataroot  = '/home1/edibled1/public_html/moodledata';
$CFG->admin     = 'admin';

$CFG->directorypermissions = 0777;

//remove these after debugging is done!
@error_reporting(E_ALL | E_STRICT);
@ini_set('display_errors', '1');
$CFG->debug = (E_ALL | E_STRICT);
$CFG->debugdisplay = 1;
 
// You can specify a comma separated list of user ids that that always see
// debug messages, this overrides the debug flag in $CFG->debug and $CFG->debugdisplay
// for these users only.
$CFG->debugusers = '2';
//end remove after debugging done

require_once(dirname(__FILE__) . '/lib/setup.php');

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Guillermo Madero -

Hello Patricia,

Glad you did.

Now! There we have the culprit of the "headers already sent by (output started at /home1/edibled1/public_html/studio/config.php:2)" error message.

At line 2 of the config.php configuraton file you added a call to PHP function phpinfo();. I won't get into the details, but you need to remove it.

You can get that same info page from within Moodle by going to: Administration > Server > PHP info.

https://docs.moodle.org/27/en/PHP

Average of ratings: Useful (1)
In reply to Guillermo Madero

Re: Unable to log in (2.6)

by Patricia Loofbourrow -

Thank you! I am able to log in. I now have my theme back as well! :D

FYI: You might want to suggest someone remove this recommendation. smile


ETA: Although I see now that I didn't do everything on that page. Maybe that would have made a difference?

I feel that the instructions on all these documentation pages should be clarified for people who are directed to these pages and unfamiliar with what they're doing or even what the terms mean. I think more people would use Moodle (and there would be a lot fewer questions here on the forums).


In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Guillermo Madero -

ETA = Edited To Add?

In reply to Guillermo Madero

Re: Unable to log in (2.6)

by Patricia Loofbourrow -

Yes, sir, that's correct. smile

In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Guillermo Madero -

Let's thank the Internet searchers then, for allowing us to solve almost any doubt smile

Having worked, many years ago, in the air travel industry, I always translated it as Estimated Time of Arrival.

In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Ken Task -
Picture of Particularly helpful Moodlers

What is on line 2 of your config.php file?

Should be a blank line and on the third a line:

<?php  // Moodle configuration file

unset($CFG);

This has to do with sessions (beginning of).   Could try this ...

In config.php add a line:

$CFG->dbsessions='0';

This tells moodle not to use the database for sessions.   In 2.6, the default is NOT to use the DB for sessions but you could have turned that on prior to moving your Moodle.

Also ... with that sessions setting, Moodle will record sessions in a file located in

moodledata/sessions/

Does a sessions folder exist in your moodledata folder?

If it does, what are ownership/permissions?   On a CentOS Linux server the sessions folder looks like:

drwxrwxrwx   2 apache apache 106496 Sep 15 09:11 sessions

It is safe to remove all files in the sessions folder.

Then attempt login again.  One should see a new file created in the sessions folder upon attempt.

Also, might want to clear all cache and cookies from your browser.

If the above doesn't work, might have to turn on debugging via the config.php file.

'spirit of sharing', Ken

In reply to Ken Task

Re: Unable to log in (2.6)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I'm not sure if I read you correctly, but the VERY FIRST characters of the config.php file should be 

<?php

There should be no space or blank line first. If in doubt, check the config-dist.php file to see what it should look like. Blank space in front of the initial <?php is also a possible cause of this problem.

In reply to Howard Miller

Re: Unable to log in (2.6)

by Ken Task -
Picture of Particularly helpful Moodlers

Hmmmm ... first line should be <?php yes.  Don't think you read it right!!!

Thought that's what I said or showed.   Have several sites on a server with this:

head -n 3 ./*/config.php
==> ./allen2/config.php <==
<?php  // Moodle configuration file

unset($CFG);

==> ./elis/config.php <==
<?php  // Moodle configuration file

unset($CFG);

==> ./ltimoodle/config.php <==
<?php  // Moodle configuration file

unset($CFG);

==> ./moodle25/config.php <==
<?php  // Moodle configuration file

unset($CFG);

==> ./moodle26/config.php <==
<?php  // Moodle configuration file

unset($CFG);

All of them function just fine.

At the very bottom of the config.php file there is this comment:

// There is no php closing tag in this file,
// it is intentional because it prevents trailing whitespace problems!

Might be that 2.6.x is not as sensitive as previous versions of Moodle were to such things as I just edited config.php trying to get the site to deny login.   No change I made to config.php format ... extra blank lines ... even a blank line after the last comment in the file, created that issue.

During a site migration FTP has been known to have hickups (if that is how the files were moved to new server).   So a strange character could 'sneak' it's way into config.php.   But, since the site was migrated to another server, it means that config.php file had to be edited.   Not using a text editor has been known to cause problems.

The errors seem to relate to sessions ... so that's why the suggestion to set sessions to no DB.  Op could then see if Moodle could write to the sessions folder or not.

Anyway ... just my 2 cents! ;)

'spirit of sharing', Ken

In reply to Ken Task

Re: Unable to log in (2.6)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

What is on line 2 of your config.php file?

Should be a blank line and on the third a line:

<?php  // Moodle configuration file


implying that <?php should be on line 3?? Just trying to avoid making it worse...

If I add a blank line in front of the initial <?php in my config.php the site pretty much is stuffed. You wouldn't miss it wink

In reply to Patricia Loofbourrow

Re: Unable to log in (2.6)

by Nitin Jain -
Picture of Plugin developers

I faced this issue once that i was not able to login after migrating my site to another server. Additionally my theme was also not loading properly.


Two things solved my problem:

1. Switching off slash arguments settings under site-administration -> server -> http

Because some servers don't support it.


2. Different DB engine - On my new server it was MyISAM DB Strage engine on my new server and it was InnoDB on my old server. Passwords compiled in InnoDB engine didn't work in MyISAM DB engine. So i had to reset my password on new server. to reset the password, try using forgot password option.


Let me if this helps.

Thanks

Nitin



In reply to Nitin Jain

Re: Unable to log in (2.6)

by Howard Miller -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

I doubt it...

The first problem also (usually) causes the theme not to load properly. Very noticable. 

The second would simply cause a normal authentication failure, not the errors noted above.

Having said that, stranger things....