A session had already been started

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 18.0.2): 19.0.0 RC1
Operating system and version (eg, Ubuntu 20.04): CentOS Linux release 7.8.2003 (Core)
Apache or nginx version (eg, Apache 2.4.25): nginx/1.17.10
PHP version (eg, 7.1): PHP 7.4.4

The issue you are facing: I have an error in the nextcloud.log after log in. session_start(): A session had already been started - ignoring at /home/mydomain/public/lib/private/Session/Internal.php#209
Any ideas why this happens?

Is this the first time you’ve seen this error? (Y/N): Y it came after webupdate from the last nc19 beta.

Steps to replicate it:

  1. Login
  2. Go to logs

The output of your Nextcloud log in Admin > Logging:

... VneO5cEID","level":3,"time":"2020-05-10T07:27:55+00:00","remoteAddr":"4.5.6.7","user":"--","app":"PHP","method":"GET","url":"/","message":"session_start(): A session had already been started - ignoring at /home/mydomain/public/lib/private/Session/Internal.php#209","userAgent":"Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36","version":"19.0.0.9"}

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

PASTE HERE

The output of your Apache/nginx/system log in /var/log/____:

4.5.6.7 - - [10/May/2020:10:27:55 +0300] "GET / HTTP/2.0" 302 0 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:56 +0300] "GET /login HTTP/2.0" 200 3832 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:57 +0300] "GET /apps/theming/js/theming?v=3 HTTP/2.0" 200 203 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:57 +0300] "GET /apps/accessibility/js/accessibility?v=0 HTTP/2.0" 200 85 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:57 +0300] "GET /apps/theming/styles?v=3 HTTP/2.0" 200 440 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:58 +0300] "GET /apps/theming/icon?v=3 HTTP/2.0" 304 0 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:58 +0300] "GET /apps/theming/favicon?v=3 HTTP/2.0" 304 0 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
4.5.6.7 - - [10/May/2020:10:27:58 +0300] "GET /apps/theming/manifest?v=3 HTTP/2.0" 200 240 "-" "Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36"
1 Like

Am I the only one with this error?

@MeiRos

nc 19 is still in beta… so it might be a bug.
but… first of all: it would make sense to update to the latest beta (RC6 oder such, i dunno) and check if this is happening, still.

if yes, please feel free to file a bug report on github - don’t forget to give out all infos they ask for… and maybe a link to this thread as well…

and after having successfully filed your issue pls don’t forget to link the issue here as an answer. which would close this thread (as there won’t be anything left that we could do here)

thanks

Hi @JimmyKater

Webupdater isn’t offering update yet, so I’ll wait for it.
I think developers are too busy, so I’d like to know if there are others with the same error. Because if I’m the only one, it’s propably my configuration. I don’t want to waste developers valuable time with errors in my configuration. :slight_smile: That’s why I started this thread.

in this case i’d suggest for the future to not install any beta-versions anymore. wait until xx.0.0 versions and then start discussing your problems here.

beta versions are there to give devs direct feedback. so why not taking the chance? they even could tell you if its a misconfiguration or not.

Looks like this is actually really old bug. https://github.com/nextcloud/server/issues/20490 So old that I didn’t even see it before.
I updated to the new rc and the error is still there.

{“reqId”:“GOlj2xCSLuvqnZ3hwgXM”,“level”:3,“time”:“2020-05-14T14:54:07+00:00”,“remoteAddr”:“4.5.6.7”,“user”:“–”,“app”:“PHP”,“method”:“GET”,“url”:“/logout?requesttoken=jMz…cXg%3D”,“message”:“session_start(): A session had already been started - ignoring at /home/mydomain/public/lib/private/Session/Internal.php#209”,“userAgent”:“Mozilla/5.0 (X11; CrOS x86_64 12871.91.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.127 Safari/537.36”,“version”:“19.0.0.10”,“id”:“5ebd5e5b5d4de”}

I followed info at nextcloudcmd fills the logs with "session_start(): A session had already been started - ignoring at /opt/nextcloud/lib/private/Session/Internal.php#205" · Issue #17185 · nextcloud/server · GitHub . In my php.ini there’s session.auto_start = 0.

Looks like the error is now actually happening when I log out from the Nextcloud. Before 11th of May there were different errors complaining about the same ‘already started’.

{“reqId”:“Gf7W15JbdlVNIkXcJSnM”,“level”:3,“time”:“2020-05-07T19:58:46+00:00”,“remoteAddr”:“4.5.6.7”,“user”:“–”,“app”:“PHP”,“method”:“GET”,“url”:“/ocs/v1.php/cloud/user?format=json”,“message”:“session_start(): A session had already been started - ignoring at /home/mydomain/public/lib/private/Session/Internal.php#209”,“userAgent”:“Mozilla/5.0 (Android) Nextcloud-android/3.12.0 RC1”,“version”:“19.0.0.9”}
{“reqId”:“i2p9iE1wYfhAPiJQcE9a”,“level”:3,“time”:“2020-05-08T23:49:41+00:00”,“remoteAddr”:“4.5.6.7”,“user”:“–”,“app”:“PHP”,“method”:“GET”,“url”:“/”,“message”:“session_start(): A session had already been started - ignoring at /home/mydomain/public/lib/private/Session/Internal.php#209”,“userAgent”:“Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36”,“version”:“19.0.0.9”}
{“reqId”:“m1mG99qLwrpVneO5cEID”,“level”:3,“time”:“2020-05-10T07:27:55+00:00”,“remoteAddr”:“4.5.6.7”,“user”:“–”,“app”:“PHP”,“method”:“GET”,“url”:“/”,“message”:“session_start(): A session had already been started - ignoring at /home/mydomain/public/lib/private/Session/Internal.php#209”,“userAgent”:“Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.122 Mobile Safari/537.36”,“version”:“19.0.0.9”}

this will close the case here on the forum as solved.

I updated to NC19 last night. Shortly thereafter, the same error began to occur.

[PHP] Error: session_start(): A session had already been started - ignoring at /MY-NEXTCLOUD/lib/private/Session/Internal.php#209

PROPFIND /remote.php/webdav/AutoRun.inf

It happens from time to time, at least on Windows when user mount it for the first time via WebDAV.

This error is occurring at least once an hour.


CentOS 7.7, PHP 7.3.19, NC19(Stable), Nginx 1.16.1

I visited the github issue and do not understand how this is solved.

I’m still receiving many occurrences of this error in my Nextcloud logfile:

session_start(): A session had already been started - ignoring at /usr/share/webapps/nextcloud/lib/private/Session/Internal.php#209

Here’s my server configuration detail:
### Server configuration detail

Operating system: Linux 5.7.2-arch1-1 #1 SMP PREEMPT Wed, 10 Jun 2020 20:36:24 +0000 x86_64

Webserver: nginx/1.19.0 (fpm-fcgi)

Database: mysql 10.4.13

PHP version: 7.4.7

Modules loaded: Core, date, libxml, openssl, pcre, zlib, ctype, dom, fileinfo, filter, hash, json, mbstring, pcntl, SPL, PDO, apcu, posix, readline, Reflection, session, SimpleXML, standard, tokenizer, xml, xmlreader, xmlwriter, mysqlnd, cgi-fcgi, bcmath, bz2, curl, exif, ftp, gd, gettext, gmp, iconv, imap, intl, mysqli, pdo_mysql, pdo_sqlite, pspell, snmp, sockets, sqlite3, tidy, xmlrpc, xsl, zip, apc, Phar, geoip, igbinary, imagick, pam, redis, smbclient, libsmbclient, Zend OPcache

Nextcloud version: 19.0.0 - 19.0.0.12

Updated from an older Nextcloud/ownCloud or fresh install:

Where did you install Nextcloud from: unknown
Signing status
List of activated apps
Configuration (config/config.php)

External storages: yes
External storage configuration

Encryption: no

User-backends:

OC\User\Database

Browser: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.97 Safari/537.36 Edg/83.0.478.45

I updated from 18.0.6 to 18.0.7 today and after that from 18.0.7.directly to 19.0.1

After all steps php occ db:… maintenance:… and so on
I realised that my logfiles show

session_start(): A session had already been started - ignoring at /var/www/nextcloud/lib/private/Session/Internal.php#209

my session.auto … is saved with = 0 under php -> fpm and cli

I also have problems to understand the solution / workaround from https://github.com/nextcloud/server/issues/20490

Any definite steps to reproduce?

I encountered the same problem after upgrading from Nextcloud “19.0.0.12” to “19.0.1.1”.

At first glance, I also didn’t understand the solution / workaround from https://github.com/nextcloud/server/issues/20490

Then I realized by reading more carefully that the solution was in the following comment :
https://github.com/nextcloud/server/issues/20490#issuecomment-645322499

At the end of this comment, you’ll find the “Update Internal.php” link pointing here :

It will show the fix you have to apply to the “lib/private/Session/Internal.php” file.

Mine is here on my Linux server, but your path might differ if you chose another web root for your installation :
/var/www/nextcloud/lib/private/Session/Internal.php

For safety reasons, I recommend making a backup of this file first.

Then, all you have to do is edit this file and look for the following function :

        public function clear() {
                $this->invoke('session_unset');
                $this->regenerateId();
                $this->startSession();
                $_SESSION = [];
        }

Then you have to comment out the “$this->startSession();” line, for it is the very line causing the bug :

        public function clear() {
                $this->invoke('session_unset');
                $this->regenerateId();
                /* $this->startSession(); */
                $_SESSION = [];
        }

You can also remove this line if you prefer. It’s up to you.

When you’re finished, don’t forget clearing your web browser cache, then just connect to your Nextcloud instance with a regular user and disconnect. Connect back as admin user to check your logs.

The “session_start(): A session had already been started” error should not be thrown again.

9 Likes

Ah thanks! That was, i was looking for :slight_smile:

1 Like

@NuageMagique: Thank you for the detailed post!

1 Like

My pleasure. :slightly_smiling_face:

works. thank you

This error is back in NC21 → 21.0.1 isn’t it?

I found this line and commented it out again

/* $this->startSession(); */

The error in NC 21 named

Error: session_start(): Ignoring session_start() because a session is already active at /var/www/nextcloud/lib/private/Session/Internal.php#207

The full error log says:

{“reqId”:“ySz11Co662nP1Ec22zS5”,“level”:3,“time”:“2021-04-18T13:38:34+02:00”,“remoteAddr”:“192.168.55.133”,“user”:“–”,“app”:“PHP”,“method”:“PROPFIND”,“url”:“/remote.php/webdav”,“message”:{“Exception”:“Error”,“Message”:“session_start(): Ignoring session_start() because a session is already active at /var/www/nextcloud/lib/private/Session/Internal.php#207”,“Code”:0,“Trace”:[{“function”:“onError”,“class”:“OC\Log\ErrorHandler”,“type”:“::”},{“function”:“session_start”},{“file”:“/var/www/nextcloud/lib/private/Session/Internal.php”,“line”:207,“function”:“call_user_func_array”},{“file”:“/var/www/nextcloud/lib/private/Session/Internal.php”,“line”:217,“function”:“invoke”,“class”:“OC\Session\Internal”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/Session/Internal.php”,“line”:107,“function”:“startSession”,“class”:“OC\Session\Internal”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/Session/CryptoSessionData.php”,“line”:150,“function”:“clear”,“class”:“OC\Session\Internal”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/User/Session.php”,“line”:932,“function”:“clear”,“class”:“OC\Session\CryptoSessionData”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/User/Session.php”,“line”:271,“function”:“logout”,“class”:“OC\User\Session”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/User/Session.php”,“line”:244,“function”:“validateSession”,“class”:“OC\User\Session”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/legacy/OC_App.php”,“line”:380,“function”:“getUser”,“class”:“OC\User\Session”,“type”:“->”},{“file”:“/var/www/nextcloud/lib/private/legacy/OC_App.php”,“line”:120,“function”:“getEnabledApps”,“class”:“OC_App”,“type”:“::”},{“file”:“/var/www/nextcloud/remote.php”,“line”:152,“function”:“loadApps”,“class”:“OC_App”,“type”:“::”}],“File”:“/var/www/nextcloud/lib/private/Log/ErrorHandler.php”,“Line”:92,“CustomMessage”:“–”},“userAgent”:“Microsoft-WebDAV-MiniRedir/10.0.19042”,“version”:“21.0.1.1”,“id”:“607c20389d6e4”}