How long they exist: until your script exits, or until you call a database close function.
How do you use them? the same way as you would any other table, as long as they last! The important differences from regular tables are (1) each connection has its own private copy of a temporary table, i.e. if you create a temp table called TEMP, then one client adding rows to TEMP goes to a separate physical table than any other client, and (2) the table is automatically dropped when the connection ends.