Sounds fine. I assume you have exit(0) after header("Location: http://example.com/login"); so no content is served.
I run exactly the same setup. The 'temp' table is a MySQL MEMORY table so lookups are very quick based on a 16 byte MD5 session hash.
Cron job is run periodically to remove older sessions.
A nice touch is to include the redirected from URL, so the user goes back to the original page they were trying to view.