<?php
namespace App\Entity;
use App\Repository\SessionRepository;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use Throwable;
/**
* @ORM\Entity(repositoryClass=SessionRepository::class)
* @ORM\Table(name="sessions")
*/
class Session
{
/**
* @ORM\Id()
* @ORM\Column(type="string")
*/
private string $sess_id;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $sess_data = null;
/**
* @ORM\Column(type="string", length=255)
*/
private string $sess_lifetime;
/**
* @ORM\Column(type="integer")
*/
private int $sess_time;
/**
* @return string
*/
public function getSessId(): string
{
return $this->sess_id;
}
/**
* @return array|null
* @throws Exception
*/
public function getSessData(): ?array
{
$result = null;
if (!empty($this->sess_data)) {
try {
if (!session_id()) {
session_start();
}
if (session_decode($this->sess_data)) {
$result = $_SESSION;
session_destroy();
}
} catch (Throwable $t) {
}
}
return $result;
}
/**
* @return string
*/
public function getSessLifetime(): string
{
return $this->sess_lifetime;
}
/**
* @return int
*/
public function getSessTime(): int
{
return $this->sess_time;
}
}