I have some thoughts about your most recent question.
This arrangement:
line 8-12
if(isset($_REQUEST['oauth_token']) && $_SESSION['token'] !== $_REQUEST['oauth_token']) {
//If token is old, distroy session and redirect user to index.php
session_destroy();
header('Location: index.php');
line 14-20
is not necessary. The line numbers are just a distraction, and they don't add any new information to the question. I have edited your question accordingly. See how much easier it is to read?
The community either has missed this, or didn't bother to read your entire post due to it's length, but at the end of the day, your question amounts to either "What's wrong with my code dump," or "How do I do ${this}?"
Code troubleshooting questions have specific requirements that you did not fulfill:
Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers.
"How do I do ${this}?" I personally prefer that you'd asked that. Unfortunately, you would have been asked "What have you tried" from the community, you would have pasted in your code, and we would be back to where we are now.