My application is currently being opened from my file system and makes requests to a server hosted on cloud 9. Whenever I submit information from the same page I make two requests from the same page.
One request is to create a new resource and the second one is to upload files. Upon completion of the first request I set a session variable that is crucial for successful processing of the second request since it is used for authentication, however when I perform the second request the variable is not there.
I am making requests with angular, I feel like that is relevant since the session id placeholder that should be stored on the client should be there after the first request but it is not, and I am stating to suspect that the way angular might be handling the requests could conflict.
In order to obtain a session id I download my application's script file while having everything else load from disk, and I do get a sid
edit probably not the best decision to keep my app's url on the png
On the client side, this is how I perform the requests.
$http.post('www.myurl.com/firstBatch',app).success(function(data)
{
var res = data;
if(res == 'true')
{
sendSecondBatch($scope, function(formData)
{
var tok = encodeURIComponent($scope.application.title);
$http.post('www.myurl.com/secondbatch', formData, {
headers : {'Content-Type' : undefined},
transformRequest : angular.identity
}).success(function(data){
//data
if(data == 'true')
{
//both of the request's succeeded
}
})
});
}
});
On the server side I have a route that handles one request and a different route handles the second.
function handleFirst()
{
//logic
req.session.myarray =['myname'];
}
and located at a different route
function handleSecond()
{
var myname = req.sesssion.myarray[0];
}
myname
is undefined suggesting that the session did not persist