S
S
Sergey2015-12-02 20:17:49
PHP
Sergey, 2015-12-02 20:17:49

How to check if a session exists?

I can't understand how it works. The code works like this, I check for isset PHPSESSID, then I have to make sure the sess_PHPSESSID file really exists. But how? I did not find a way, there is only one thought, to check files by name. But there must be an easier way. And if you write session_start(); a session will be created, check whether it is empty for any first value, it will be empty at least as well as delete it. But it looks like nonsense, create and delete. =\
The story of how: I was looking for something without knowing what I was going there without knowing where

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2015-12-02
@chelovekmuravei

The answer is

session_start();
if(isset($_SESSION['ххх'])) { 
echo "Сессия существует"; 
}
else { 
session_destroy();
echo "Такой сессии не существует";
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question