How to use SSO (Discourse on subdomain)

Last question please about get_key() and set_key() functions

// pretend that set_key is a function that saves key value data in a database

Initially we store the nonce in a database (a single column table ?)
When Discourse respond, we just check if nonce exists in the table ?
If yes, we store login infos received from Discourse with the $_GET
(then store in PHP session…)

Is it ok ?