<?php
declare(strict_types=1);

namespace Nette\Bridges\HttpTracy;

use Tracy\Dumper;
use Tracy\Helpers;

?>
<style class="tracy-debug">
	#tracy-debug .nette-SessionPanel-parameters pre {
		background: #FDF5CE;
		padding: .4em .7em;
		border: 1px dotted silver;
		overflow: auto;
	}
</style>

<h1>Session #<?= Helpers::escapeHtml(substr(session_id(), 0, 10)) ?>… (Lifetime: <?= Helpers::escapeHtml(ini_get('session.cookie_lifetime')); ?>)</h1>

<div class="tracy-inner nette-SessionPanel">
	<?php if (empty($_SESSION)):?>
	<p><i>empty</i></p>
	<?php else: ?>
	<table class="tracy-sortable">
	<?php
	foreach ($_SESSION as $k => $v) {
		if ($k === '__NF') {
			$k = 'Nette Session';
			$v = $v['DATA'] ?? null;
		} elseif ($k === '_tracy') {
			continue;
		}
		echo '<tr><th>', Helpers::escapeHtml($k), '</th><td>', Dumper::toHtml($v, [Dumper::LIVE => true]), "</td></tr>\n";
	}?>
	</table>
	<?php endif ?>
</div>
