# Are all these steps necessary with prepared statement?

Are all these steps correct and necessary?

<?php
if (isset($_SESSION['userID'])) {$userID = $_SESSION['userID'];$stmt = $mysqli->prepare( "SELECT usergroup, firstname FROM tbl_users WHERE userID = ? ");$stmt->bind_param('i', $userID);$stmt->execute();
$stmt->store_result();$stmt->bind_result($usergroup,$firstname);
$stmt->fetch();$_SESSION['usergroup'] = $usergroup;$_SESSION['firstname'] = $firstname;$stmt->close();
}
?>


More or less, they are... I was using get_result and fetching object more often, but if you want to have the results bound directly to variables, your code is what you need.