Only on my hosting - session_start(): Cannot send Session cache Limiter

Asked

Viewed 36 times

1

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/grupoemais/public_html/cameder.com.br/consulta/index.php:1) in /home/grupoemais/public_html/cameder.com.br/consulta/classes/Sessao.class.php on line 13

http://www.cameder.com.br/consulta/

I would like to know how I can solve the problems of this system, it presents 2, 1 of them is a consequence of the other.

**On the Xamp server works perfectly, on the Godaddy server it does not work.

The code perfectly caught the only page that was changed was the index php. down below:

<?

ob_start();

require('includes/config.inc.php');

define('TITLE', '');

define('DESCRIPTION', '');

?>

<!DOCTYPE HTML>

<html>

<head>

    <?php require('includes/head.inc.php'); ?>

</head>



<body>

    <!-- HEADER -->

    <?php require('includes/header.inc.php'); ?>



    <div id="content">

        <?php

        if (!empty($_SESSION['login']))

        {

            if ($rowU['nivel'] === '0')

                $Funcoes->redirecionar('/consultas');

            else

                $Funcoes->redirecionar('/minhas-consultas');

        }

        else

        {

            if (!empty($_POST))

            {

                $Sessao->gravar();



                if (!empty($_POST['cliente']))

                {

                    $Formulario->validarCampo('text', 'E-mail', 'cli_email', true, 6, 60);

                    $Formulario->validarCampo('text', 'Senha', 'cli_senha', true, 6, 20);

                    if (!empty($_SESSION['alerta']))

                    {

                        $Funcoes->redirecionar('/?cliente=true', 'erro');

                    }



                    $query = 'SELECT id FROM usuarios WHERE email=:email AND senha=:senha';

                    $result = $BancoDeDados->prepare($query);

                    $result->bindValue(':email', $_POST['cli_email']);

                    $result->bindValue(':senha', md5($_POST['cli_senha']));

                    $result->execute();



                    if ($result->rowCount() === 0)

                    {

                        $Funcoes->alerta('Usuário e senha incorretos.');

                        $Funcoes->redirecionar('/?cliente=true', 'erro');

                    }



                    $row = $result->fetch(PDO::FETCH_ASSOC);



                    $_SESSION['login']['id'] = $row['id'];



                    $Funcoes->redirecionar('/');

                }

                else

                {

                    $Formulario->validarCampo('text', 'Nome', 'ncli_nome', true, 6, 60);

                    $Formulario->validarCampo('text', 'CPF', 'ncli_cpf', true, 14, 14);

                    $Formulario->validarCampo('text', 'E-mail', 'ncli_email', true, 6, 60);

                    $Formulario->validarCampo('text', 'Senha', 'ncli_senha', true, 6, 20);

                    $Formulario->validarCampo('text', 'Repita a senha', 'ncli_senha2', true, 6, 20);

                    if (!empty($_SESSION['alerta']))

                    {

                        $Funcoes->redirecionar('/?cliente=false', 'erro');

                    }



                    $query = 'SELECT email, cpf FROM usuarios WHERE email=:email OR cpf=:cpf';

                    $result = $BancoDeDados->prepare($query);

                    $result->bindValue(':email', $_POST['ncli_email']);

                    $result->bindValue(':cpf', $_POST['ncli_cpf']);

                    $result->execute();



                    if ($result->rowCount() > 0)

                    {

                        $row = $result->fetch(PDO::FETCH_ASSOC);



                        if ($row['cpf'] === $_POST['ncli_cpf'])

                        {

                            $Funcoes->alerta('CPF já cadastrado!');

                            $Funcoes->redirecionar('/?cliente=false', 'erro');

                        }

                        elseif ($row['email'] === $_POST['ncli_email'])

                        {

                            $Funcoes->alerta('E-mail já cadastrado!');

                            $Funcoes->redirecionar('/?cliente=false', 'erro');

                        }

                    }



                    if ($_POST['ncli_senha'] !== $_POST['ncli_senha2'])

                    {

                        $Funcoes->alerta('As senhas não coincidem.');

                        $Funcoes->redirecionar('/?cliente=false', 'erro');

                    }



                    try

                    {

                        $BancoDeDados->beginTransaction();

                        $query = 'INSERT INTO usuarios (nivel, nome, cpf, email, senha) VALUES (:nivel, :nome, :cpf, :email, :senha)';

                        $result = $BancoDeDados->prepare($query);

                        $result->bindValue(':nivel', '1');

                        $result->bindValue(':nome', $_POST

['ncli_nome']);

                        $result->bindValue(':cpf', $_POST

['ncli_cpf']);

                        $result->bindValue(':email', $_POST

['ncli_email']);

                        $result->bindValue(':senha', md5($_POST

['ncli_senha']));

                        $result->execute();

                        $idUsuario = $BancoDeDados->lastInsertId();



                        $BancoDeDados->commit();

                    }

                    catch (Exception $e)

                    {

                        $Funcoes->redirecionar('/?cliente=false', 

'erro');

                    }



                    $_SESSION['login']['id'] = $idUsuario;



                    $Funcoes->redirecionar('/comprar-consultas');

                }

            }

            ?>

            <form method="post" enctype="multipart/form-data" class="colA">

                <h1>JÁ SOU CLIENTE</h1>

                <?php if (!empty($_GET['cliente']) && $_GET['cliente'] === 'true') $Funcoes->exibirAlerta(); ?>

                <label>

                    <span>E-mail</span>

                    <input type="email" name="cli_email" maxlength="60" value="<?= $Formulario->valorCampo('text', 'cli_email'); ?>" required autofocus />

                </label>

                <label>

                    <span>Senha</span>

                    <input type="password" name="cli_senha" maxlength="20" required />

                </label>

                <input type="submit" name="cliente" value="ACESSAR" />

            </form>

            <form method="post" enctype="multipart/form-data" class="colB">

                <h1>AINDA NÃO SOU CLIENTE</h1>

                <?php if (!empty($_GET['cliente']) && $_GET['cliente'] === 'false') $Funcoes->exibirAlerta(); ?>

                <label>

                    <span>Nome</span>

                    <input type="text" name="ncli_nome" maxlength="60" value="<?= $Formulario->valorCampo('text', 'ncli_nome'); ?>" required />

                </label>

                <label>

                    <span>CPF</span>

                    <input type="text" name="ncli_cpf" value="<?= 

$Formulario->valorCampo('text', 'ncli_cpf'); ?>" required />

                </label>

                <label>

                    <span>E-mail</span>

                    <input type="email" name="ncli_email" maxlength="60" value="<?= $Formulario->valorCampo('text', 'ncli_email'); ?>" required />

                </label>

                <label>

                    <span>Senha</span>

                    <input type="password" name="ncli_senha" maxlength="20" required />

                </label>

                <label>

                    <span>Repita a senha</span>

                    <input type="password" name="ncli_senha2" maxlength="20" required />

                </label>

                <input type="submit" name="naocliente" value="CADASTRAR" />

            </form>

            <div class="clear"></div>

            <?php

        }

        ?>

    </div>



    <!-- FOOTER -->

    <?php require('includes/footer.inc.php'); ?>



    <!-- SCRIPTS -->

    <?php require('includes/scripts.inc.php'); ?>

    <script src="<?= URL; ?>/js/jquery.maskedinput.js"></script>

    <script>

        $(document).ready(function()

        {

            $("input[name=ncli_cpf]").mask("999.999.999-99");

        });

    </script>

</body>

</html>

<?php

$Sessao->limpar();
  • The only line that was changed had been in the body of the page and now nothing else works.

  • Probably the session ( session_start() is declared in the includes/head.inc.php file and includes/header.inc.php. Deletes a session_start()

  • Updating here guys, in my lodging is not getting and the local code is !! This is driving me crazy.

  • See if this link helps you http://blog.thiagobelem.net/resolvendo-o-problema-de-headers-already-sent

  • In the worst case, add an arroba in Session_start() (Not recommended). Plus the problem should be that the login or session check is after some HTML

Show 1 more comment
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.