Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

282
Views
How to find device information while setting cookies in nodejs?

I have checked two packages express-session and cookie-parser. I need to find the user's trusted device information. When a user tries to log in from another device. I need to find it. Is it possible to find it like that?

When I used express-session I added a user name to the cookie, when logging in. But I tried to log in with the wrong password I could not get the cookies.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use node-device-detector to get the device information on the login and you can use it in a cookie.

const DeviceDetector = require('node-device-detector');
const detector = new DeviceDetector({
  clientIndexes: true,
  deviceIndexes: true,
  deviceAliasCode: false,
});
const userAgent = 'Mozilla/5.0 (Linux; Android 5.0; NX505J Build/KVT49L) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.78 Mobile Safari/537.36';
const result = detector.detect(userAgent);
console.log('result parse', result);

Results:

{ 
  os: { 
    name: 'Android',            // os name       
    short_name: 'AND',          // os short code name (format A-Z0-9{3})
    version: '5.0',             // os version
    platform: '',               // os platform (x64, x32, amd etc.)
    family: 'Android'           // os family
  },
  client:  { 
    type: 'browser',            // client type 
    name: 'Chrome Mobile',      // client name name
    short_name: 'CM',           // client short code name (only browser, format A-Z0-9{2,3})
    version: '43.0.2357.78',    // client version
    engine: 'Blink',            // client engine name (only browser)
    engine_version: ''          // client engine version (only browser)
    family: 'Chrome'            // client family (only browser)
  },
  device: { 
    id: 'ZT',                   // short code device brand name (format A-Z0-9{2,3})
    type: 'smartphone',         // device type
    brand: 'ZTE',               // device brand name
    model: 'Nubia Z7 max'       // device model name
    code: 'NX505J'              // device model code  (only result for enable detector.deviceAliasCode) 
  }
}

You can add cookies like this, you also need a cookie parser:

res.cookie('cookieName', 'addHereYourValues', { expires: new Date(Date.now() + 900000), httpOnly: true })

check here to know more about them.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!