Ethan22 wrote:I've heard by programmers in the past that sessions aren't preferred
In the past, saying the Earth was round instead of flat wasn't "preferred" either. That doesn't necessarily mean that you should take others' preferences as facts, however. 😉
Ethan22 wrote:they will time out by default in 20 minutes
Sessions don't "time out" at all. Sessions are (by default) nothing more than files on a server's hard drive, after all. The only thing that would destroy a session prematurely is if two conditions were met:
The session hasn't been opened (in other words: the related file hasn't been accessed) within the past X seconds, where X is defined by the PHP directive session.gc_maxlifetime.
PHP's garbage collection (GC) routine was executed as the result of a random number generated; see PHP directives session.gc_probability and session.gc_divisor
So no, your statement above is not correct.
Ethan22 wrote:when cookies and databases don't do that
Cookies expire whenever you tell them to expire (much like sessions). Note that since session ID's are often propagated from one request to another via cookies, you've got two expiration times which are unrelated to each other; session file expiration and cookie expiration.
Not sure why you're even referring to databases at all here, though, since they have no correlation to what you're talking about.
Ethan22 wrote:So if a person closes their browser and comes back the session info ended when they closed their browser, and things aren't held with sessions.
That's only true if that is how you use sessions. It doesn't have to be that way.
Ethan22 wrote:Also that sessions in a way are cookies because they still hold id's if it's a usual session that holds ids like these $_SESSION['variablegettingpassed']
Not sure what you're referring to, since you talk about "id's" and yet your example refers to a PHP array. You're comparing apples to oranges. Actually, since those are both foods, I would say it's more like you're comparing apples to cannonballs. A session only has one "id" - the SID or [man]session_id[/man].
In other words, I have no idea what you're trying to say here, but I suspect that it relates to a fundamental misunderstanding of how sessions and/or cookies work.
Ethan22 wrote:So if a person clears all their cookies in the browser it will clear id sessions like these also. So sessions like these are cleared also when anyone clears all their cookies.
Again, that's only true if that is how you use sessions. No one said you must use cookies to propagate the session ID - feel free to use the URL/query string approach if you think that better suits your needs/target audience/etc.
Ethan22 wrote:And if there are any good advantages to sessions in situations like these?
What situations? I didn't see any situations at all in your post above.