Upload image with GD library
Fight the urge to squeeze multiple "things" into one line.  Your script will be easier to read and maintain with all declarations and constructs occupying their own rightful place.  Spend the extra lines, you'll be happy you did a year from now.
Use curly braces to encapsulate language constructs (e.g. if-else and foreach, etc.), this combined with appropriate tabbing will make your script easier to read and help to prevent mishaps when expressing conditional outcomes.  Start but don't stop reading about coding standards here: https://blog.sideci.com/5-php-coding-standards-you-will-love-and-how-to-use-them-adf6a4855696
Instead of murdering your script with die() calls, return a consistent data type no matter the outcome.  In the future, you may change how you want to display/deliver the results. Finally, convert your returned array to json and echo.
When writing variables into a query, you should be using a prepared statement  with placeholders and bound variables.
Avoid single-use and unnecessary variable declarations.  If you have $_SESSION['avatar'] then you don't need to declare $name.
Starting your session is not a conditional thing.  Do it early and do it every time.
You might like to ask yourself why you've elected to write static methods.  This is a topic worth investing some research time into.  Start, but don't stop here: When should I use static methods?


There is more to tell you, but I have run out of time.