CodeIgniter Forums

Full Version: Session Without Cookies
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]Tickk[/eluser]
Hi,
Any suggestion / example how can I modified CI so CI Session doesnt use cookies anymore ?

I read at Wiki, there's some 3rd class like Native Session or PHPSession but it looks like for CI 1.5

Any working class with CI >1.7 ?

Thank you
Best regards

El Forum

[eluser]kgill[/eluser]
The only way to really do sessions without cookies is to embed the session ID in the URL or submit the session ID via POST. Submitting via post isn't entirely practical since you're probably going to have links on your webpages and you don't want to submit a form every time you wish to go to a new page so that leaves embedding it in the URL. I'm pretty sure you can figure that part out so lets get to the other issue here, why do you want to get rid of cookies? Unless you're coding for mobile platforms that can't do cookies - make your life easier and use them.

El Forum

[eluser]Christoffer[/eluser]
You could use native PHP sessions instead of CI-sessions. Don't forget to use <?php session_start(); ?> on every page though.

El Forum

[eluser]Neophyte[/eluser]
Native PHP sessions also set a session id in a cookie, it's as kgill said.

El Forum

[eluser]Tickk[/eluser]
The reason is some of my web visitor can't register, login etc access pages that need session.
First I thought the browser. But I tried IE 6,7,8, Firefox, Opera, Chrome at my computer, all runs well.
And I got reported that some client use IE, some of them use Firefox and they cant access it. But the other use the same browser can access.

Than I thought it would be the session. The session is lost during page transition.
I tried use db for session and still the problem remain.

I tried search here and at Google, I found several developer got same problem, I tried their solution still cant solve the problem.

My last guess is the cookies. So I ask about using session without cookies.

If any of you guys can give me some idea whats wrong with my web, I would really appreciate it.

Thank you.

El Forum

[eluser]darkhouse[/eluser]
I needed something similar as IE doesn't like any of the session libraries here, including the default CI session library. So one my colleagues wrote this and it works great.

http://codeigniter.com/wiki/Session_Hybrid/

It uses native PHP sessions to manage the session id, ip, user agent and last activity, and then stores all session data in the database. It's a drop in replacement, so no extra work needs to be done to use it.

Hope that helps.

El Forum

[eluser]Tickk[/eluser]
[quote author="darkhouse" date="1247418055"]I needed something similar as IE doesn't like any of the session libraries here, including the default CI session library. So one my colleagues wrote this and it works great.

http://codeigniter.com/wiki/Session_Hybrid/

It uses native PHP sessions to manage the session id, ip, user agent and last activity, and then stores all session data in the database. It's a drop in replacement, so no extra work needs to be done to use it.

Hope that helps.[/quote]

Thank you DarkHouse.
I already implemented the script.
Now, I'am waiting respoonse from my client. I hope this will solve the problem.

El Forum

[eluser]Tickk[/eluser]
Hi,
After 2 days using Hybrid Session, I still got the same problem.
But not as much as before. I got 1-3 complains from +/- 300 visitor per day.
Before almost 10 complain every day.

The strange is, some session work for him ( visitor who got problem ), and some session not work.
The session is lost between 2 view from 1 controller.

Any other suggestion to check or modified would be great.
Thank you

El Forum

[eluser]darkhouse[/eluser]
The next step is to find out everything you can about those users. What platform are they on? What browsers are they using? And most importantly, what are they doing when they lose their session? Maybe it's a problem in your code - the Session Hybrid has solved all of my problems, but I only had issues with IE. If your users are using other browsers, then it's probably an issue with your code. Maybe you're accidentally unsetting something somewhere, or overwriting something. That's about all I can say.