How to enable PHP native sessions in codeigniter? - php

I'm trying to integrate Facebook's API in a CodeIgniter project, however it seems to be not working because sessions are disabled somehow in CodeIgniter. (Trying to integrate outside CodeIgniter works, but inside a codeigniter project it doesn't work).
Is there any way to do this? All I want is for native sessions to not be cleared or destroyed by CodeIgniter. If the only way is to hack the core to remove a line or two, then I'm willing to do it. I think there's someplace where its doing $_SESSION = null or something like that. Where's this place, so I can remove that line?

If you follow this blog on a fresh CI install, it works without any problem:
http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/
From there, you can continue to build you application, or find where it goes wrong.

in CI session are not disabled.
It must be done in your manual coding.
Please refer your coding again.
It is also possible that some jQuery - JS is conflicted in project, which can destroy session.

There is a library to extend CI sessions (which are cookies) to use native server sessions.
Have a look at this native session library.

Related

How we setup cakephp 3.x without database?

In our project we don't need a database, so how do we setup cakephp 3.x on a local machine without modifying the database config? I have this issue when I'm running my site.
Error: Class 'PDO' not found
File /usr/share/nginx/dchannel/vendor/cakephp/cakephp/src/Database/Type.php
Line: 100
So please suggest a better way to do disable the database on cakephp 3.x
Thank you in advance.
Theoretically that should be possible if you just avoid to touch anything that interacts with the datbase, or uses PDO related constants and stuff, like the Type classes that are by default involved in the applications bootstrap:
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L174-L189
Also you cannot use Migrations or DebugKit, as both require PDO:
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L206-L207
https://github.com/cakephp/app/blob/3.5.0/config/bootstrap.php#L211-L217
If you comment these snippets, and do not touch the model layer anywhere, then it should work. However I don't think that there is a guarantee that this will continue to work. If you want to make sure you can ask the core devs over at Slack or IRC, or maybe even open a ticket on GitHub.
I think it is possible because cakephp use its own design template. so just replace the template with your one .
php default template \src\Template\Pages\home.ctp
I don't think it's possible to set up CakePHP without a database; it is basically a frontend to a database so the tool doesn't work without one, and I think it also uses it to store some of its configuration. If you don't need a database, then I advise you choose a different framework.

How to activate sessions in LUMEN 5.2

Im new to Lumen and i need to use the Session functionality, but based on the change log in the site. Sessions was excluded in the latest release, I already looked up in the documentation of Lumen 5.2, it says that i should refer to Laravel way of activating session and something like that. my problem is I have no experience using in Laravel too. Can anyone tell me, a step by step way to activate Lumen Sessions?
or can anyone suggest a third-party library?
There is no built-in session support in Lumen. From the release notes:
... sessions and views are no longer included with the framework. If you need access to these features, you should use the full Laravel framework.
You should install the Laravel framework instead of Lumen and refer its docs on sessions.
Also, the default PHP sessions are still available.

Zend session in multi module website

I am trying to a write a multi-module application in ZF2 but i am facing some weird problem of session.
Session are getting destroyed automatically when i am switching the modules in browser.
Is there any way to share single session accros all the modules.
Thanks
Do you use ZF2 session Manager?
if yes, you probably configure your session in a single module and the other can't find the config

APC as a session handler using Symfony components

I'm using Symfony components in my web application. I need to store session in APC but unfortunatelly I can't find the way to do it.
As I see here Symfony does not support APC as a session handler. Is that true?
I have found an old example of using APC as a session handler in Symfony. But there all configuration is done in factories.yml file which I don't have since I'm only using standalone Symfony components.
Can anyone give me an example of using APC as a session handler using only Symfony components?
Since I don't get any answer here for a long time I will answer the question myself. For now there is no built in suport for APC as a session handler in Symphony framework. There is no particlar reason for it, likely Symphony developers just did not get to it.
The solution is simple, just code APCSessionHandler.php file yourself (I was not doing it because we decided not use this in project), APCSessionHandler will be very similar to MemcachedSessionHandler.php file.
How to store PHP sessions in APC Cache? suggests it is feasible but a bad idea for a busy site. The accepted answer lists a few useful ideas

Kohana sessions and files not under the framework

I'm working on a site that is using the Kohana framework. So far I've been fine jumping in and taking over the project. Today I'm implementing a few 3rd-party features that need to use a session variable. I can set the session variable and use it fine on pages that are using controllers to serve them up, but if I make ajax calls or in this instance calls to the 3rd party page, the session data is not available to me.
I cannot figure this one out. I've tried a few things from the Kohana forums, but nothing seems to work.
Visual example:
html
html/application
controller files
ajax.php
third-party.php
If I call up ajax.php I cannot access the session data that I am setting inside "kohana" pages.
my system/config/session.php file is using 'cookie' as the driver. Expiration and Regenerate are set to 0.
Any ideas?
That's because you're using the cookie session driver. You'd probably be able to get access if you were using the 'native' driver, which uses the internal php session.
As asked above, is there some reason you're not building the ajax.php within Kohana? That would save you a lot of trouble.
On the other hand, it's possible to decrypt the session from within your external ajax.php (which I wouldn't recommend, but have had to do in order to get the kohana session data passed to a WordPress installation running on a subdomain).
From what you say about the session configuration I think you are using Kohana 2.x.
And Kohana 2 clears the $_GLOBALS. So you might have problems accessing native $_POST, $_COOKIE, $_SESSION, $_GET, $_GLOBALS and $_REQUEST arrays.
I recommend using the native driver for the session library, but I highly recommend even more migrating to Kohana 3.x.

Categories