like in classic PHP we use the magic variables to start,create session, so how to do that in Symfony.
+5
A:
It's really easy:
- You go to google.com.
- You type
symfony sessions
and hit enter. - You click on the first link.
- You search for
session
on that page, read and learn.
Sorry for possibly sounding rude, but you could save us and yourself a lot of time and hassle, if you start with searching, first - at least for these relatively easy questions (especially regarding frameworks).
And, just to be polite: In your controller, you can access session variables through the user object.
// Get a session value
$name = $this->getUser()->getAttribute('name', 'default_value');
// Set a session value
$this->getUser()->setAttribute('name', $value);
Franz
2009-11-19 09:03:07
Many questions on this site could be found by looking up the problem in Google, however I think directing people there would be missing the point. Having a definitive answer which is tagged and which can be kept relevant by wiki edits is of value to the programming community.
Jon Winstanley
2009-11-20 08:06:03
Yes, you're right, especially since I gave answers like you to other people who weren't willing to provide the real answer...
Franz
2009-11-20 09:14:42
That's why I gave the answer in the end, after googling.. ;)
Franz
2009-11-20 09:50:54
Another thing, I have started preferring S.O over google for all programming related questions, even the easy ones [API searches not included], because most of the time, the answers I get here are more useful. I don't know if that was the original intent...
sjobe
2009-11-20 14:39:07