Get and use username of logged in user on main site too

So, its probably a easy solusion, but i cant find it.
I want to use the login system for Owncloud to work for rest of my site not only on OC.
So is there a doc on how to set the $_SESSION or somethink like that?