http://php.net/manual/en/function.array-unique.php
You are going about this the hard way. Once the user is logged in, their group information is already in the $_SESSION. You don’t need to add them in every time. And I do not remember ever seeing an instance where there were multiple instances of a group name placed in the $_SESSION by MODx.
You can treat $_SESSION[’webUserGroupNames’] like any other array.
Maybe, you need to make a protected page and then place a snippet in it with:
<?php
print_r($_SESSION);
?>
you could also
print_r($_SESSION['webUserGroupNames']);
To see what is in it. It will only work on logged in people, as that is how the $_SESSION is created.
A $_SESSION of 20,000 variables? I would be considering a cleaner solution.
20,000 variables x 100,000 people or even 150 people is huge on the memory.
Using extract() is not a decent solution either.