|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2002-04-27 10:29 UTC] siebe_tolsma at hotmail dot com
Hi, I try to make a script with sessions, but when I use the command session_start() in my script, PHP crashes. I don't know what causes it, so please help me. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 12 10:00:01 2025 UTC |
I'm also trying that. I load a translation (from a JSON file, which one gets loaded is chosen by the user) and if I then immediately `die();` it works. If I put the `die();` after the `session_start();` it returns error 500. This is the script as of writing the comment: ```PHP <?php // Load translation in requested language or German $transl = json_decode(file_get_contents('transl-'.((isset($_GET['l']) && in_array($_GET['l'], ['de', 'en', 'sv'])) ? $_GET['l'] : 'de').'.json')); var_dump($transl); //debug, works // die('Debug 1'); //debug, works when not commented-out // Set user type to guest if no session is running or fail to deliver files if it's a file fetching request start_session(); die(); //debug, doesn't work if (!isset($_SESSION['ut'])) { $_SESSION['ut'] = 'g'; } if (!in_array($_SESSION['ut'], ['g', 'u', 'a'])) { // ut→usertype g→guest u→user a→admin session_destroy(); header('Content-type: text/html; encoding=utf-8'); die('<!DOCTYPE html> <html> <head> <title>'.$transl->title_sesserr_type.' • Lampe2020.de</title> </head> </html>'); } if (!((isset($_SESSION['un']) && isset($_SESSION['pw'])))&&($_SESSION['un']!='' && $_SESSION['pw']!='')) { // un→username pw→password $_SESSION['ut'] = 'g'; } ?> ```