Establish independent server session for an ajax request?

By : Inator
Source: Stackoverflow.com
Question!

I have a set of PHP server side scripts that maintain user session state using PHP sessions extensively throughout for a logged in user.

Client side in a mobile app, via Jquery ajax, I need to establish an independent session (authenticated as a different user) that does not disrupt the already established session. In other words, to the server it must look like a different browser session.

Is there a way to programmatically accomplish this with Jquery/Javascript client side for only a specific request?

By : Inator


Answers
Sessions in PHP are transmitted using an identifier, which is generally passed as a cookie -- see the Passing the Session ID section of the manual.

This means that if that identifier (cookie) is not passed to the Ajax query, then, the PHP script called via that query will not consider that the user is the same ; and will see him as a different one.

So, basically : you must find a way to not pass that session identifier, when doing your Ajax request.
Of course : don't delete the cookie : it must remain here, for the other kind of requests, if you don't want your use to lose his session.



Maybe, but it probably would be better to use a different server/domain that doesn't share session information with the original server/domain.



This video can help you solving your question :)
By: admin