You haven't made it clear where $meminfo[id] is coming from.
If you've got register_globals enabled, and it's coming from the request, then this is extremely vulnerable to attacks.
Why not use PHP's built in sessions functionality? It supports storing sessions in a database.
Generally speaking, if you want a session to expire, it's not necessary to do anything much other than let the cookies expire and occasionally clean out old sessions from the database. This doesn't need to be done very often.
Mark