Hi.
I was trying to do an login option for my ACS web site so user can mark it and don't need to login each time he closes the browser. I did some searchs and found some close questions to this, but almost all was for mobile apps, no for Node ACS.
Well, what I tried till now was to login initially and save the data.meta.session_id into a cookie (with a week expiration time):
ACS.Users.login({ // Get fields from form login: req.body.username, password: req.body.password }, function(data) { if (data.success) { // Set session data to be used later througout the app req.session.session_id = data.meta.session_id; res.cookie('session', req.session.session_id, {maxAge:60*60*24, httpOnly: true}); } else { res.redirect('/error?type=1'); } });Then, when the user closes the browser I still have the session alive in the cookie. When he comes back I do this:
if (req.cookies.session) { req.session.session_id = req.cookies.session; }Which seems valid, but now I need to access my user data and when I try this I get an error:
var ACS = require('acs').ACS; ACS.sessionId = req.cookies.session; ACS.Users.showMe(function (e) { if (e.success) { var user = e.users[0]; console.log('Success:\n' + 'id: ' + user.id + '\n' + 'first name: ' + user.first_name + '\n' + 'last name: ' + user.last_name); } else { console.log('Error:\n' + ((e.error && e.message) || JSON.stringify(e))); } }); Error: You need to sign in or sign up before continuingHow can I access my user data? Or this is not a valid method? Any other way to recover the user session to avoid continuosly login in?