I dabble in PHP. In the projects I’ve done I always use the database and a cookie to handle sessions. I’ve seen “session functions” such as session_start() being used also in other sources. I’m just curious, which is better? Should I be using one or another?
Share
Well, there’s three ways that I’ve used through-out time:
$_COOKIE-way, meaning that you actually use cookies to store values$_SESSION-way, where you use an associative array that probably relies on a cookie$_SESSIONin conjunction with the DB, making sessions controllable on a user-basis.I prefer using option #3, as it both enables me to alter sessions “on-the-fly”, as well as track the logged in users easier.
Options #3 would play out in the following way (semi-pseudo):