I am trying to use symfony2 sessions.I do this
    $session = $this->getRequest()->getSession();
    $session->set('token','value');
This works. But i want to use namespace in session. Documentation says
    class NamespacedAttributeBag 
provides that feature but i cannot figure out how to implement it
Just open your config.yml and after imports add:
parameters:
    session.attribute_bag.class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag
It looks like this:
imports:
    - { resource: parameters.yml }
    - { resource: security.yml }
parameters:
    session.attribute_bag.class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag
framework:
# ...
                        You should redefine session service and also define service for your attribute bag (if you'll check default implementation of session.attribute_bag you'll see that this service has only class attribute). 
And inject your new service to redefined session service into there
services:
    session:
        class: Symfony\Component\HttpFoundation\Session\Session
        arguments:
            - @session.storage
            - @your.session.attribute_bag #service id is defined below
            - @session.flash_bag
    your.session.attribute_bag:
        class: Symfony\Component\HttpFoundation\Session\Attribute\NamespacedAttributeBag
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With