1

On my application I need to extend the user session, but Sync Gateway REST Api don't have a put method to extend the expiration time. And I'm creating a function to update the expiration meta data of the session document direct on the database. Something like this

var couchbaseObj = require('couchbase')
var clusterObj = new couchbaseObj.Cluster('couchbase://127.0.0.1')
// For Couchbase > 4.5 with RBAC Auth
clusterObj.authenticate('user', 'password')
var bucketObj = clusterObj.openBucket('data')

bucketObj.getAndTouch(sessionKey, 10000, function (err, result) {
  if (err) {
    return(err)
  }
  return(null)
})

My question is, what is the risk of doing this? Is there a better way to update the session expiration time on Sync Gateway? Why Sync Gateway don't have a put method to update session?

  • Why do you need to extend the session expiration? The sync gateway generates the session and guarantees that it will be valid for the duration of the replication. The Sync Gateway is responsible for managing the session life time- you shouldn't be messing around with that. – rajagp Jul 14 '20 at 03:20

0 Answers0