Facebook php sdk 4 getSessionFromRedirect() always null

Solved: I entered the code outside of the ajax call, in function my_footer() {