NetTalk Central

Author Topic: How to delete another session nr  (Read 1594 times)

Alberto

  • Hero Member
  • *****
  • Posts: 1846
    • MSN Messenger - alberto-michelis@hotmail.com
    • View Profile
    • ARMi software solutions
    • Email
How to delete another session nr
« on: June 19, 2010, 07:14:45 AM »
Hi,
I need the web server to be used with one user from one IP at a time.
That is, User1 log in from one computer (IP 1),
If another user try to log in with the same user/pass of User1 from another machine (IP2)
I want to delete de User1 session and allow the User2 to log in.
My problem is how to delete and logued out automatically the User1, knowing its SessionID, from the LogIn Form procedure.

I´m trying with

      p_web.SetSessionLoggedIn(0)
      p_web.DeleteSession(PST:Session_Nr)

but it obiously does not work.

Thanks
Alberto


-----------
Regards
Alberto

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11183
    • View Profile
Re: How to delete another session nr
« Reply #1 on: June 21, 2010, 12:38:40 AM »
your problem breaks down quite easily into a number of steps;

a) when a user wants to log in;
check the session queue to see if a _session_ exists with the same user.

b) if it does, delete _that_ session from the session queue.

Of course you can't use the normal session functions to do this, because they work on the _current_ session, and you want to access a _different_ session.

I'll assume that after a person logs in your put their login name into a session variable called "LoggedInUser". It's this that we'll use to determine if the user is already logged in.

p_web.RequestData.WebServer._Wait()
found = 0
Loop x = 1 to records(p_web.RequestData.WebServer._SessionDataQueue)
  get(p_web.RequestData.WebServer._SessionDataQueue,x)
  if p_web.RequestData.WebServer._SessionDataQueue.Name = 'LoggedInUser' and |
     upper(p_web.RequestData.WebServer._SessionDataQueue.Value) = upper(loc:login)
     found = p_web.RequestData.WebServer._SessionDataQueue.SessionId
     break
  end
end
p_web.RequestData.WebServer._Release()
If found
  p_web.RequestData.WebServer._DeleteSession(found)
end