0

I am working on symfony 1.0 and to set a variable value into the session, we usually do is:

$this->getUser()->setAttribute('method', 'ajax');

But this will not work if no user session is set.

I want to set a variable into the session so that even after many redirects or untill I manualy clear it, it should be available to use.

This $this->setFlash('attrib', $value); will erase out once made an another request.

How can this be seen in symfony- I mean having a variable in session untill it is cleared manually.

j0k
  • 22,600
  • 28
  • 79
  • 90
Manojkumar
  • 1,351
  • 5
  • 35
  • 63
  • `setFlash` use the same way to store value in session: `$this->setAttribute($name, $value, 'symfony/user/sfUser/flash');` – j0k Nov 23 '12 at 12:32
  • @j0k: `setFlash` keeps the values till another request is made. Bt I want to have a variable value in session even after many redirections. How is this possible in symfony. I can either use `$_SESSION['variable']="value"`. I want some specific method in sym,fony. – Manojkumar Nov 23 '12 at 12:59
  • I don't know why, but the first code you write is ok for session: http://stackoverflow.com/questions/1761552/how-to-use-sessions-in-symfony – j0k Nov 23 '12 at 13:01
  • @j0k: yes But it cannot be used if NO user is logged in. my requirement is simple. I set a session in one action file and after 2 redirections, I want to use it. How it can be achieved? – Manojkumar Nov 23 '12 at 13:04
  • There is always a session even for anonymous request, look at factory.yml under `all: storage` – sglessard Nov 23 '12 at 14:49

0 Answers0