public function checkSession()
 {
     if (UserSession::where('user_id', '=', Input::get('userId'))->exists()) {
         $sessionData = UserSession::where('user_id', Input::get('userId'))->first();
         $currentTime = date('Y-m-d H:i:s');
         $sessionTime = $sessionData['updated_at'];
         $totalTime = strtotime($currentTime) - strtotime($sessionTime);
         $allowedTime = 7200;
         # 2 hours
         if ($totalTime > 7200) {
             UserSession::where('user_id', Input::get('userId'))->delete();
             $Response = array('success' => '0', 'error' => 'Session Expired');
         } else {
             $updateUserSession['updated_at'] = $currentTime;
             UserSession::where('user_id', '=', Input::get('userId'))->update($updateUserSession);
             $Response = array('success' => '1');
         }
         return $Response;
     }
 }
 /**
  * @param id
  * @param $token
  * @return Response
  */
 public static function startUserSession($id, $token)
 {
     //start a user session
     //        Session::put($token, $id);
     //        Session::save();
     $session = UserSession::firstOrNew(['payload_id' => $id]);
     $session->token = $token;
     $session->payload_id = $id;
     $session->save();
 }