Jump to content
McKay Development

Recommended Posts

Posted

Hi,
I'm trying to forcefully kill the cookies so that it will trigger the sessionExpired event. However, this does not seem to happen. I cannot get the sessionExpired event to trigger and after some digging around I'm unsure what I could have done wrongly.

Code
 

// Scripts
const config = require('../config');

// Modules
const fs = require('fs');
const SteamCommunity = require('steamcommunity');
const SteamTotp = require('steam-totp');
const TradeOfferManager = require('steam-tradeoffer-manager');
const SteamUser = require('steam-user');

// States
let community = new SteamCommunity();
let client = new SteamUser();
let manager = new TradeOfferManager({
  steam: client,
  pollInterval: 5000,
  community
});

let { username, password, secret } = config.settings.platforms.steam.authentication;
let options = {
  accountName: username,
  password,
  twoFactorCode: SteamTotp.generateAuthCode(secret.shared)
}

client.logOn(options);

client.on('loggedOn', () => {
  console.log('bot has logged in');

  client.gamesPlayed(730);
  client.setPersona(SteamUser.EPersonaState.Online);
});

client.on('webSession', (session, cookies) => {
  manager.setCookies(cookies, function(err) {
    if(err) console.error(err);
    console.log('got api key');
  });
  community.setCookies(cookies);
});

// sessionexpired never
community.on('sessionExpired', (err) => {
  console.log('SESSION EXPIRED');

  // do webLogOn with delay
});

// manual kill the session
setTimeout(function() {
  console.log('killing session..');
  community.setCookies(["sessionid=1||invalid", "steamLogin=1||invalid", "steamLoginSecure=1||invalid"]);
}, 35 * 1000);

 

Posted

Have you tried making any requests after you set your cookies to invalid values? It can't know the session has expired until it tries to make an authenticated request and Steam redirects us back to the login page.

Posted
6 hours ago, Dr. McKay said:

Have you tried making any requests after you set your cookies to invalid values? It can't know the session has expired until it tries to make an authenticated request and Steam redirects us back to the login page.

Huge facepalm right there, I even remember reading about it on the docs. Thanks, that's it, I never initiated anything to trigger the event.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...