<?php

include 'sessionLogin.php';
$login = new SessionLogin();
$login->isUserLogged();
?>

<h2>Itens no carrinho:</h2>

<div class="alert alert-danger" ng-show="displayMessageError" role="alert">
	<p>{{messageError}}</p>
</div>

<div class="alert alert-info" ng-show="displayMessage" role="alert">
	<p>{{message}}</p>
</div>


<div ng-init="loadCartFromSessionStorage()">

	<table class="table table-bordered"> 
		<thead class="text-center">
			<th>Produto</th>
			<th>Valor</th>
			<th>Excluir</th>
		</thead>
		
		<tbody>
			<tr ng-repeat="product in cartItens">
				<td>{{product.nome}}</td>
				<td>{{product.preco | currency:"R$"}}</td>
class SessionLogin
{
    public function createSession()
    {
        if (isset($_POST['data'])) {
            $data = $_POST['data'];
            if (!empty($data)) {
                $nome = $data['nome'];
                $id = $data['id'];
                if (!empty($nome) && !empty($id)) {
                    session_start();
                    $_SESSION['nome'] = $nome;
                    $_SESSION['id'] = $id;
                    $_SESSION['isValidUser'] = '******';
                    header('Content-type: application/json');
                    $responseArray['status'] = 'success';
                    echo json_encode($responseArray);
                }
            }
        }
    }
    public function isUserLogged()
    {
        session_start();
        if (!isset($_SESSION['isValidUser']) || $_SESSION['isValidUser'] == 'INVALIDO') {
            header("Location: login.php?envio=login_errado");
        }
    }
}
$login = new SessionLogin();
$login->createSession();