Keeping session data tidy
Our session data handler can be asked to delete a session, a process that follows similar logic to the one just described:
public function sess_destroy ($session_id) { setcookie ('aliroTempSession', null, time()-7*24*60*60, '/'); if (!isset($_COOKIE['aliroCookieCheck']) OR !isset($this->db)) return true; $session_id = $this->db->getEscaped($session_id); $this->db->doSQL("DELETE FROM #__session_data WHERE session_ id_crc = CRC32('$session_id') AND session_id = '$session_ id'"); return true; }
As you can see, deletion is simpler than reading, since the temporary session data cookie can be deleted regardless of whether it presently exists. Provided cookies are accepted and the database is available, the relevant session data record can be deleted. It does not matter if there is no such record, since SQL deletions simply delete whatever matches the WHERE
condition, and do not mind if nothing matches.
In principle, keeping things tidy on the basis of expiration...