Search code examples
phpfoursquare

How to have a session variable during a foursquare redirect


I am trying to keep the username variable alive while I redirect to foursquare for oauth purposes. I am using Amazon EC2 servers. Here is the relevant code:

session_start();
if (isset($_GET['username']))
{
    $_SESSION['username'] = $_GET['username']
    header("Location: https://foursquare.com/oauth2/authenticate?clientid=(clientidHere)&responsetype=code&redirect_uri=http://redirecturi");
}
if (isset($_GET['code']))
{ 
    echo $_SESSION['username'];
}

Solution

  • I found that I just had to use cookies.