Concrete5 sessions and other thoughts

Permalink
I have just started developing with Concrete5 v5.7 having come over from application framework world (CodeIgniter/Laravel/Cake etc). Generally I am very happy with what I am finding. Nice and robust, straight forward and my client is very happy with the out of the box features (particularly the content editing stuff). My only small complaint is around documentation. I find it hard to dig up examples of standard basic stuff. Eg it took me way to long to find out that the site name was retrievable from the config not an attribute. For anyone who stumbles upon this the site name is available by using
Config::get('concrete.site');
- easy when you know how...

Now the other thing I am finding it hard to find any info on is handling sessions. Does Concrete5 v5.7 even have a session handling class? If so can anyone point me to the page in the API docs? I will be surprised (but also relieved that I am not going mad) to find that we should be messing around with sessions by just chucking stuff at $_SESSION like in the good old days of native hackery?? Particularly with all the change to support namespacing in 5.7 it would seem mad that there wasnt a core method to handle namespacing variables in $_SESSION. Any ideas anyone?

mikemiller
 
theneptune replied on at Permalink Reply
theneptune
mikemiller replied on at Permalink Reply
mikemiller
Much obliged. Not sure why I was unable to find that myself. Bit of documentation blindness has set in I think.

I still cant see any method for setting/getting user session data.. Is there anything to handle this?
theneptune replied on at Permalink Reply
theneptune
Yes the documentation is little bit not user friendly like codeignitor. But once you go through it, not so complicated.
Thanks.
mikemiller replied on at Permalink Reply
mikemiller
Its cool I am familiar with the format but I am still unable to find any method that will allow me to get and set session variables in a safe way. Ie a way where I dont inadvertently overwrite something the core relies on or the other way round. What is the recognised approach for writing a value to the session for example?? I cannot find mention of this anywhere apart from old posts showing code snippets using
$_SESSION['some_key']='some_potentially_dangerouns_value';
theneptune replied on at Permalink Reply
theneptune
mikemiller replied on at Permalink Reply
mikemiller
Nope doesnt look like it. I will assume (unless anyone corrects me) that there isnt such a thing and will write my own..

For further bit of clarity what I expected to see was an equivalent controller method to
$this->post();
that looks a lot like
$this->session();
RadiantWeb replied on at Permalink Best Answer Reply
RadiantWeb
use \Symfony\Component\HttpFoundation\Session\Session as SymfonySession;
...
$session = new SymfonySession();
$session->set('package.context.param',$value);
$val = $session->get('package.context.param');
$session->remove('package.context.param');


ChadStrat
mikemiller replied on at Permalink Reply
mikemiller
Oh!! Your a total legend.. of course its a symfony component THATS why I couldn't find it in the docs... seriously this should be somewhere more obvious. Thanks a bazillion!!