Can one have Temporary Rows? I understand that Temporary Tables in Postgres and MS SQL Server persist until the end of the session. When the user’s session ends, any temp tables created by that user are dropped automatically. The temp table is not visible between users. 

I need both the visibility across user sessions and the temporary nature where the data disappears when the user session ends (either closes gracefully or breaks). 

Is there any way to have a permanent table visible to all but temporary rows? Is there any automatic way to have a user’s inserted rows disappear at the end of their session, yet be visible to other users during that session?
You can make a procedure/job that cleans up the tables.  It would:


Check if the user is active
If so, ignore and move on to the next user or complete
If not, truncate/delete the table (after moving the records to a historical table if you desire)


Rinse/repeat every xx minutes.

We have used some variation of this in production. I usually do the coding in a stored procedure, and the "repeat" part comes from a SQL Server Agent job, which executes the procedure on a schedule.  I try to keep it as modular as I can.