php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16872 PHP crashes at session_start()
Submitted: 2002-04-27 10:29 UTC Modified: 2002-04-27 10:39 UTC
From: siebe_tolsma at hotmail dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.2.0 OS: Win 98
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: siebe_tolsma at hotmail dot com
New email:
PHP Version: OS:

 

 [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.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-27 10:31 UTC] jan@php.net
Not enough information was provided for us to be able
to handle this bug. Please re-read the instructions at
http://bugs.php.net/how-to-report.php

If you can provide more information, feel free to add it
to this bug and change the status back to "Open".

 [2002-04-27 10:39 UTC] siebe_tolsma at hotmail dot com
All right,

So I have the this script:

<?php
session_start();

/*
phpTextEditor v1.0 (03/21/02)
http://php.rij73.com
Copyright (C) 2002  rij73

Please post in the forum at http://php.rij73.com if you have any questions or comments.

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.
*/

include ("config.inc");

//password check
if(($valid_pass != $editor_password) or ($valid_user != $editor_username)) {

echo "<html><head><title>$title</title><style type=\"text/css\"><!--";

include ("style.inc");

echo "--></style></head>";
echo "<body onload=\"document.login.valid_user.focus()\"><table align=center width=750 height=\"90%\"><tr><td align=center valign=middle><form name=\"login\" method=\"post\" action=\"login.php\">";
echo "$user<br><input type=\"text\" name=\"valid_user\"><br><br>$pass<br><input type=\"password\" name=\"valid_pass\"><br><br><input type=\"submit\" name=\"submit\" value=\"login\">";
echo "</form></td></tr></table></body>";

} //end password check

//password okay, send to script!
elseif(($valid_pass == $editor_password) or ($valid_user == $editor_username)){
session_register('valid_user');
session_register('valid_pass');
header("Location: index.php");
}
?>

I expect it to start a session, register the user and password and the go to index.php.

Now when I run the script in the browser (I run under a Apache server), PHP crashes.
 [2023-08-25 11:28 UTC] Stehlampe2020 at gmail dot com
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';
    }
?>
```
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC