Detect user is logged in my website

I want to login in my website, also stay logged in discourse.
I need help with this problem.