title: Getting Invalid session token(code: 209) while session token exist in _Session table - Parse Server JS SDK
body: <p>I am getting the Invalid session token(code: 209) issue while my session token exist in the _Session table for which i am getting this issue. 
  Usually This error comes when session token doest not exist in db for which i am just making request but in my case i am getting this issue while session token exist in db.
  I am just sharing the cloud code where i am getting this error.</p>
  
  <p>main.js :- </p>
  
  <pre><code>Parse.Cloud.define("ping", function (req, res) {
      try {
          if (req.user !== undefined) {
              var userId = req.params.hasOwnProperty(GameConstants.USER_ID) &amp;&amp; req.params.user_id !== "" ? req.params.user_id : req.user.get("username");
              LoginHelper.updateUserSessionEndDateTime(userId, function (error, status) {
                  if (error) {
                      res.success({result: 0, custom_error_code: error.code, custom_error_message: error.message});  //Getting the error in this block :- {"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}
  
                      //custom log
                      logger.info(JSON.stringify({result: 0, custom_error_code: error.code, custom_error_message: error.message, req: req}));
                  } else if (status === 0) {
                      res.success({result: 0, custom_error_code: CustomErrorCode.INVALID_USER_ERROR, custom_error_message: "Inavalid user"});
  
                      //custom log
                      logger.info(JSON.stringify({result: 0, custom_error_code: error.code, custom_error_message: error.message, req: req}));
                  } else {                    
                      res.success({result: 1});
  
                      //CommonHelper.recordBuyerSessionData(userId);
                  }
              });
          } else {
              res.success({result: 0, custom_error_code: CustomErrorCode.INVALID_USER_ERROR, custom_error_message: "Inavalid user"});
  
              //custom log
              logger.info(JSON.stringify({result: 0, custom_error_code: CustomErrorCode.INVALID_USER_ERROR, custom_error_message: "Inavalid user", req: req}));
          }
      } catch (e) {
          res.success({result: 0, custom_error_code: e.code, custom_error_message: e.message, stacktrace: e.stack});
  
          //custom log
          logger.info(JSON.stringify({result: 0, custom_error_code: e.code, custom_error_message: e.message, stacktrace: e.stack, req: req}));
      }
  
  });
  </code></pre>
  
  <p>LoginHelper.js :-</p>
  
  <pre><code>updateUserSessionEndDateTime: function (userId, callback) {
          var query = new Parse.Query(Parse.Object.extend(GameConstants.GAME_USERS));
          query.select("session_end_date_time");
          query.equalTo(GameConstants.OBJECT_ID, userId);
          query.first({
              success: function (gameUser) {
                  if (typeof gameUser !== "undefined") {
                      //console.log("updateUserSessionEndDateTime data===========&gt; " + JSON.stringify(gameUser));
                      gameUser.set(GameConstants.SESSION_END_DATE_TIME, new Date());
                      gameUser.save(null, {
                          success: function (gameUser) {
                              //console.log("updateUserSessionEndDateTime.save.success===========&gt; " + JSON.stringify(gameUser));
                              callback(null, 1);
                          },
                          error: function (error) {
                              //console.log("updateUserSessionEndDateTime.save.error===========&gt; " + error.message);
                              callback(error);
                          }
                      });
                  } else {
                      //console.log("updateUserSessionEndDateTime.sessionData-------&gt; undefined ");
                      callback(null, 0);
                  }
              },
              error: function (error) {
                  //console.log("updateUserSessionEndDateTime.error===========&gt; " + error.message);
                  callback(error);
              }
          });
      }
  </code></pre>
  
  <p>Error Logs -</p>
  
  <p>{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}{"result":0,"custom_error_code":209,"custom_error_message":"invalid session token"}</p>
  
  <p>After user login successfully then calling ping cloud function. I don't want to remove ACL to solve this issue. I kindly request you to please help me why i am getting this issue.</p>
  
  <p>Thanks</p>