Get variable from URL - Works in straight php


The else portion of my code doesn’t work with a Kirby plugin. I use the domain.

When I use this simular code in php it works. When I put it in Kirby, the else portion doesn’t work. Also the main domain puts a / in front of my domain like so.

So what I need to do is make it so that kirby can get the ?token=value from the url and put it in the webservice value. Any suggestions what I’m doing wrong? Thanks.

//Cookie check goes here. else get token from url.  If cookie parse it and set variables for pendo.
// else do the below code.
// Check cookie exisits. if it does
// 2 parse it
// 3 set variables this prevents a unique request to the webservices each time.
This portion of the code works

// if token exists get it from the url and get the value back from webservices. I shouldn't need an exception if the token is set and working. Although I thought about checking it just in case. But the token should be set and working.
    if (isset($_GET['token'])) {
        $token = $_GET['token'];

        $tokenData = file_get_contents(''.$token);

// set cookie variables should still be set from the webservices. but create the cookie and serialize it.

        $json = json_encode($tokenData);
        setcookie('resourceCenter', $tokenData, time() + 3600, '/');

        $roleSummary = json_decode($tokenData);
        echo "somethingelse";


        echo "somethingwrong";




I think the question is where the code fails.
Have you checked the PHP error log?
Do you get a result if you var_dump($token)? (it does not matter if there is a slash or not, you should still get the token from the URL.
Does the code work if you hardcode the token?