What are the potential benefits and drawbacks of storing answers in a PHP session instead of a database for a tool that is used for a few minutes?

Storing answers in a PHP session instead of a database for a tool used for a few minutes can provide faster access to the data and reduce the need for database queries. However, sessions are limited by server resources and may not be suitable for large amounts of data or long-term storage. Additionally, if the session expires or is lost, the data will be inaccessible.

<?php
session_start();

// Store answers in session variable
$_SESSION['answers'] = ['answer1', 'answer2', 'answer3'];

// Access answers from session
$answers = $_SESSION['answers'];

// Unset session variable when done
unset($_SESSION['answers']);