Jump to content
McKay Development

sessionExpired is never called


Recommended Posts

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.


// 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,

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


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


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

// 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);


Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.


  • Create New...