CodeIgniter Forums

Full Version: Maintaining a session with two CI applications
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]ToretoTech[/eluser]
I have somewhat of a unique issue that I can use some help with. I currently have two CI applications: A web service and a web client. The client sends requests to the service using PECL_HTTP. I have them both communicating to each other just fine.

The only thing is, I create a session for the client on the service which I'd like to be transferred transparently to the client. I do this by grabbing the Set-Cookie from the header of the response and then create a new session on the client with the value being the session returned from the service. This only works until the service stale timer [sess_time_to_update] runs out. At this point, the service creates TWO session variables, one with nothing stored to it, and the other still being the good one. This causes a problem for me because I am only expecting one cookie on the client, so what happens is the client ends up getting logged out because of an invalid session.

The service is using sessions with a DB and the client is only using the browser to store sessions.

My question is, is there any reason why the service is creating a second session var when the [sess_time_to_update] expires. Does it have something to do with the fact that all the requests are being made with PECL_HTTP and not an actual browser?

Thanks in advance for any help.

El Forum

[eluser]ToretoTech[/eluser]
So going over my issue I have found that the easiest way to get around this is by avoiding the use of the Cookie and pass the cookie back and forth from my service manually. To do this, I'd have to override the existing Session class to stop using cookies and I'd have to pass in the session and return the session accordingly.

I am curious to know if anyone has ever done anything like this and if there are any points that I should be aware of going forward with this.

Cheers

El Forum

[eluser]ToretoTech[/eluser]
**UPDATE**

So I have been doing some research and I have noticed that the reason behind having multiple sessions created is coming from using PECL to send requests to the service. I am thinking it is happening when I manually attach the cookie in the PECL request back to the service. What I'm thinking is that when the service gets the request and sees that it's time to update the session, for some reason it doesn't match the session ID and creates a new empty session and returns that to the client – which then logs the user out.

My question now is, has anyone successfully made PECL calls to a CI application that was using sessions?

Cheers