Leave a self-joined session - session

I understood by reading the source code that the method leaveSession of the BusAttachment can't be called on a self-joined session. So, how to leave a self-joined session?

Does the call fail? This may be an issue where the documentation is inconsistent with the code. The Java bindings merely call the C++ code, and the C++ code doesn't appear to have a problem leaving self-joined sessions.

I was also having a problem when using the leaveSession method. The error I get from the bus is:
ER_ALLJOYN_LEAVESESSION_REPLY_NO_SESSION
However, when I use the leaveHostedSession, the host leaves the session with success.
Mind that the session lost event will not be fired at the clients if more than one client remains in the session.

Related

How to add a flashdata after session_write_close()

I upgraded my application from CI2 to CI3 (CI v3.1.9 and PHP7). Now I have performance issue with the new concurrency system in the session (see doc).
Some of the actions in the application are very long (because of calling an external APIs that can takes several minutes to respond for example) and I don't want those actions to lock the session. As recommended, I would use session_write_close() function in the controller before doing the very long action.
The problem is that I want to display a message to user after redirecting at the end of this action. Right now, I am using session->set_flashdata() before the redirection, but because I closed the session earlier, it is not working.
Does anyone have recommendations on how to achieve that?
If I am starting the session again with session_start() it is working, but I have no idea if this is best practice to use PHP session like that with Codeigniter.
There is no problem with starting the session again using session_start(). The CodeIgniter "Session" class is still loaded and the instance is still valid. So all the "special" stuff that CI does to make sessions work is good to go.
I tested and then used this scheme in a project some time back and didn't experience any problems. Haven't had any blow-back from the client of a still operating site either. YMMV.
BTW, in the __construct() function of the CI_Session class a call to session_start() is made in order to start up PHP's session extension. So making that call is clearly not a "bad" practice. :)

How to generate log in service now when a browser is closed?

I need to generate logs in service now whenever the browser is closed or the session is expired. I tried using global business rule but couldnt achieve it. It will be greatfull if i can if i get an idea to achieve this.
Thanks in advance.
I assume you already know how to generate a log and such in ServiceNow, and the problem you're having, is how to run code when the user closed their browser.
The best solution would probably be to create an onload client script which sets onbeforeunload to a function that triggers a log.
More on that here: https://developer.mozilla.org/en-US/docs/Web/API/WindowEventHandlers/onbeforeunload
For the second part of your question, user sessions are tracked in a "user sessions" table. If you want to also log when theirs expires, you can do so with a business rule on that table.
You can use
GlideAjax to call from your client script to a server side script include.
Look at GSLog
Try this one
var gl = new GSLog("com.snc.sla.tasksla.log", "TaskSLA");

Why Does Session Abandon Not Work?

I have following code
cx5_login.asp
Session("Login") = "demo"
cx5_logout.asp :
Session("Login") = ""
Session.Abandon
response.redirect "c5x_login.asp?C5xName=Login"
I want to know if Session.Abandon will remove Session("Login")?
Currenly, I am check for Session("Login") to determinate if the user is login or not.
But it doesn't work.
Scenario:
User login
User logout
I print value from Session("Login") and it's still have value.
I have called Session.Abandon but why Session("Login") still have value?
Is it related with ASPSESSIONID cookie?
I try to remove that cookie manually and it's work.
Any explanation for this?
What Neel say's isn't wrong but it isn't right either, the problem is and constantly tends to be either question askers or people answering confusing Classic ASP with ASP.Net.
If your question is Classic ASP related then when talking about the Session object you need to consider the following.
Session.Abandon() should be used to completely dispose a session including the Session.SessionID.
But there is a cavert;
Quote from the MSDN Library - Session.Abandon()
"When the Abandon method is called, the current Session object is queued for deletion but is not actually deleted until all of the script commands on the current page have been processed. This means that you can access variables stored in the Session object on the same page as the call to the Abandon method but not in any subsequent Web pages."
This means that within the context of the current page your Session is still available, it isn't until you move on to another page that the Session object is actually disposed.
If you don't redirect after your log out page your Session will still be accessible but rest assured that any attempt to access it after leaving that page will fail.
As a test don't automatically redirect after logout but give the users a link to press and see if you get the same behaviour.

Tracking down mysterious session-ending bug

I'm using Codeigniter/PyroCMS which uses ion_auth.
I have my session stuff set for two hours. I'm using db sessions.
There is a gremlin somewhere that is booting the session after n minutes, sometimes. It is very random, and as such is hard impossible to reliably reproduce.
I've added log entries to the Session class (specifically sess_destroy) but that merely logs the session being destroyed, which I already knew.
I tried to add a debug_backtrace() into said log entry, but that aint jiving with teh codes (it doesn't get logged/it spits it onto the screen for a split second before the !session redirect).
Is there a good/proper way to track this down?
Thanks guise.
update: I added a few more log entries in Session.php Turns out the db session is being deleted/overwritten incorrectly. WHAI?
This seems a problem quite common. I have used (and happily accepted as recommendation)
Codeigniter's Native session (there is a download link at the bottom)
BUT, due that it is an old library you MUST made some hacks. You can check those simple hacks in the library's forum
Just drop this file in codeigniter's library directory and see if resolve your problem. Please feedback.
Sounds like your session cookie is prematurely expiring. Start by checking the settings in your config file for your session related stuff. Namely the $config['sess_expiration'] value, which defaults to 7200. Which is 2 hours.
Then check your php.ini, which I believe defaults to 3600. (1 hr)
Otherwise, I would say that if your code is on a unix system, try a
grep -Rn 'sess_destroy' .
The other thing you might want to look for is anyplace that is attempting to possibly write NULLs or empty values to the session. It's possible that you don't have a sess_destroy anywhere, but that you could have something to the effect of unset($_SESSION).
Hope this helps.
It appears to have been an issue with the server and resolve.conf mapping things incorrectly.

How to trace CakePHP's inner workflow

Short description
I'm getting used to CakePHP right now and am wondering about how to get more debug-information about what is happening inside the framework.
Let me please explain my situation a little more detailed
As you know CakePHP does a lot for you without putting you into the need to write additional code. One example is the handling of models.
I just created a model User and added validation-rules (no other methods). As described in the API methods like save will just work.
After that I created the needed controller and view to add a new user. When I try to add a user from the view I just receive the flash-message The user could not be created. Please, try again. No validation-violations are flashed.
I also did set the debug-level to 2: Configure::write('debug', 2); but do not receive any errors. The error.log inside \tmp\logs is also empty.
I really do want to learn how to solve those issues in the future.
So what else can I do to debug / display inner processes of cake?
Thank you very much for your help!
DebugKit is an official plugin that gives you lots of information on the request, queries and variables produced by Cake:
https://github.com/cakephp/debug_kit
You can also use trace() and other methods in the Debugger to show what is being executed in the background:
http://book.cakephp.org/2.0/en/development/debugging.html
Use a PHP IDE with an integrated debugger. That will allow you to follow execution line by line as it is executed and even inspect variable values as you go. Netbeans is a free one.

Resources