0

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

SID

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

Alan
  • 1,134
  • 2
  • 13
  • 25
  • I wonder if this may have something to do with *"My application is currently being opened from my file system"*. Weird things happen when doing so, usually in the name of security. – Kevin B Jul 09 '15 at 18:38
  • are the sessions managed server side or client side? – deostroll Jul 09 '15 at 18:38
  • @deostroll Sessions are managed server side via connect-redis store. – Alan Jul 09 '15 at 18:47
  • @KevinB I also have the suspicion that that might be it since after I perform the requests there isnt a connect session id under the resources > cookies > server name. I proceeded to load my script file from the server every time I opened the page and I get a session id but the variable still doesnt persists. I would really like to avoid for now uploading all my files to the server and having to download the from there, I want to test my app's logic first – Alan Jul 09 '15 at 18:51
  • you could do that through a local webserver pretty easily. – Kevin B Jul 09 '15 at 18:58
  • I added a bit more context. – Alan Jul 09 '15 at 19:15

0 Answers0