I've tried saving the access token as a key/value pair in the $_SESSION variable, but if
a) I encrypt it and then save it, on the next page or request, it has changed or
b) I don't encrypt it and save it as a string, it is deleted from $_SESSION on the next page.
What am I doing wrong here? I need to make multiple requests in sequence and have a feeling I shouldn't need to ask for a new access token with each one. Thanks!
Submitted
Official response from Arion HardisonCan you paste the code?
I have a few questions here
1) Why are you encrypting the access token?
2) When you say "save" you just as a session variable or are you saving to a DB?
3) How are you saving it to $_SESSION and do you have this issue with any other variables? If so check your PHP version because $_SESSION and other register globals were deprecated in 5.3 and removed in 5.4
I would guess you are doing something like (see below)
<?php
session_start();
$_SESSION['token']=<access token here>;
?>
If you are losing your the value on the next page perhaps you are not passing a session identifier and calling session_start which would cause a new session to start.
Showing 4 reactions
Sign in with
However, now I’m actually running into an issue with passing page and per_page parameters; if I make a call without either of these parameters, the data is returned as expected. As soon as I pass either page=2 or per_page=100 etc, I receive an unauthorized message.
Here is one for example:
<code>$result = $client->fetch(’https://blahblah.nationbuilder.com/api/v1/people?page=2');</code>