Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SessionHandler::write(): Parent session handler is not open

I'm using FOSFacebookBundle in Symfony 2.3 as it says in the Integration with FOSUserBundle documentation. And edited security.yml, ran the code but I got the error:

Warning: SessionHandler::write(): Parent session handler is not open in /var/www/my/app/cache/dev/classes.php line 407

so I gave the permissions:

sudo chmod 777 -R app/cache
sudo chmod 777 -R app/logs

When I login again, and then logout page I get the same error.

I see this https://github.com/symfony/symfony/issues/5868 and update the php.

But this problem is not solve I don't know why ? Any one know please tell me ?

security.yml

security:
encoders:
    FOS\UserBundle\Model\UserInterface: sha512

role_hierarchy:
    ROLE_ADMIN:       ROLE_USER
    ROLE_SUPER_ADMIN: ROLE_ADMIN

providers:
    chain_provider:
      chain:
        providers: [fos_userbundle, my_fos_facebook_provider]
    fos_userbundle:
        id: fos_user.user_provider.username
    my_fos_facebook_provider:
        id: my.facebook.user    

firewalls:
    main:
        pattern: ^/
        fos_facebook:
            app_url: "http://apps.facebook.com/xxxx/"
            server_url: "http://symfony/app_dev.php/login"
            login_path: /login
            check_path: /loginFb
            default_target_path: /
            provider: my_fos_facebook_provider
        form_login:
            login_path: /login
            check_path: /login_check     
            provider: fos_userbundle
        logout:       true
        anonymous:    true

access_control:
    - { path: ^/secured/.*, role: [IS_AUTHENTICATED_FULLY] }
    - { path: ^/.*, role: [IS_AUTHENTICATED_ANONYMOUSLY] }
    - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY }
    - { path: ^/admin/, role: ROLE_ADMIN }
like image 509
Kunwar Siddharth Singh Avatar asked Aug 22 '13 13:08

Kunwar Siddharth Singh


People also ask

What is the use of @sessionhandler in PHP?

SessionHandler is a special class that can be used to expose the current internal PHP session save handler by inheritance. There are seven methods which wrap the seven internal session save handler callbacks ( open, close , read, write , destroy, gc and create_sid ).

How to override the current save handlers in sessionhandler?

When a plain instance of SessionHandler is set as the save handler using session_set_save_handler () it will wrap the current save handlers. A class extending from SessionHandler allows you to override the methods or intercept or filter them by calls the parent class methods which ultimately wrap the internal PHP session handlers.

What is the use of a class extending sessionhandler?

A class extending from SessionHandler allows you to override the methods or intercept or filter them by calls the parent class methods which ultimately wrap the internal PHP session handlers.

Why can't I get session_ID () from my session handler?

Your custom session handler should not contain calls to any of the session functions, such as session_name () or session_id (), as the relevant values are passed as arguments on various handler methods. Attempting to obtain values from alternative sources may not work as expected. Here is a wrapper to log in a file each session's operations.


Video Answer


2 Answers

The problem like mentionned in the ticket on github is a bug related to PHP so there is noting to do in the Symfony2 side.

Consider moving away from your current php 5.4.x to a newer version.

According to this comming you should be at least using >= php 5.4.11

See this commit

like image 161
sf_tristanb Avatar answered Oct 22 '22 18:10

sf_tristanb


Fast solution could be:

logout:
    invalidate_session: false

EDIT:

Be aware session will not be destroyed after logout. I would recommend @Tristan solution.

like image 37
Jekis Avatar answered Oct 22 '22 19:10

Jekis