Rewrite PHP session detection method. No need to store result in DB opti...

...on as it's fast already.

Follow-up of #2767 .