Help with IF and ELSE in session_start ()

0

I ask the help of my friends, because I'm having trouble creating an IF / ELSE to determine what content of the $logo variable will come first.

This is what I need when accessing the main page " link ", the "Easy Easy" > As it is in the mentioned address for access ) believing that SESSION has not yet been loaded. But after changing the image via Adm. Panel ( Access by address mentioned ), the new image will be loaded.

For this I tried to create the PHP code ( below) to determine when session_start() should load the variable for the image that was changed, but as I mention at the beginning of POST, because even after the image exchange, it continues to carry the Easy Easy logo.

<?php
if(!isset($_SESSION)) { // Se a Session não for iniciada
    $logo = 'img/logo_tipo.png'; // Carrega esse conteúdo
}else{ // Se não
@session_start(); // Inicia a session.
if(isset($_SESSION)) { // Se a Session for iniciada
    $logo = ''.$_SESSION['logo'].''; // Carrega esse conteúdo
}}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252" />
    <title></title>
    <link rel="shortcut icon" href="" />
</head>

<body style="margin:0;">

    <div align="center" style=" margin-top:5px; width:100%;">

 <img  width="150" height="auto" src="<?php echo $logo; ?>" /><br />

    </div>

</body>
</html>

Well thank the attention of friends, and waiting for good tips to solve my problem, if you have a solution.

Hugs to all.

    
asked by anonymous 22.05.2016 / 20:42

3 answers

1

You can do this, I would do so:

When the Image is set:

session_start(); // isto existe sempre
$_SESSION['Logo'] = 'COLOCADA/ADMIN/IMAGEM.jpp'; // Definir uma imagem 'default', caso ainda não se tenha colocado uma nova entretanto

if(isset($_SESSION['iniciada'])) {
     $_SESSION['Logo'] = 'NOVA/IMAGEM.JPG';
}

....
<img  width="150" height="auto" src="<?php echo $_SESSION['Logo']; ?>" /><br />
    
22.05.2016 / 21:53
0
<?php
session_start(); // Inicia a session.
if($_SESSION['logo']==FALSE) { // Se a Session não for iniciada
    $logo = 'img/logo_tipo.png'; // Carrega esse conteúdo
}else{ // Se não
    $logo = $_SESSION['logo']; // Carrega esse conteúdo
}
?>

I would do it this way

    
22.05.2016 / 20:54
0

Attempts to start the section at the beginning of the code, and at if it checks ...

          if(!isset($_SESSION['logo'])){}

If it's not right, then you might not have the right question.

    
22.05.2016 / 20:56