I have a problem with on of my sites and need some help.

I have a site that uses cookies store a UserID that is used in that session. Recently I added that a user can have diffrent profiles so I craeted a ProfileID can user in stead of userID. All good and well, but now I have problem is becoming bigger as the site grows.

Problem: Log user out if the user opens a new browesr tab

Kind regards

Why do you want to log out the user just because they opened a new browser tab? Aren't they allowed to cruise the net AND be on your site?
If you have an issue with users signing in with more than one account at the same time then you need a better way of controlling that. Is that your problem?
If yes, then I would suggest having all ProfileIDs linked to a UserID (so you know which user has the profiles) then if a profile logs in of a user that has another logged in profile you can log out the first or redirect them to the first profile account.