CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • CRM_Core_Session... Should I set my session variables to CRM_Core_Session
Pages: [1]

Author Topic: CRM_Core_Session... Should I set my session variables to CRM_Core_Session  (Read 1308 times)

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
CRM_Core_Session... Should I set my session variables to CRM_Core_Session
December 21, 2012, 04:50:36 pm
Hi there,

I'm spending the holidays (and the last month or so), really getting to know civiCRM as much as I can so I can build useful and unobtrusive extensions.

Every now and again, I need to set or get a session variable and in my current project there are a couple of session variables which I am dealing with like any PHP session. Would it be a better practice to put them in the CRM_Core_Session object for safe keeping?

Thanks,
Andrew
My CiviCRM Extension Workshop: https://github.com/awasson

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: CRM_Core_Session... Should I set my session variables to CRM_Core_Session
December 22, 2012, 02:09:30 am
Hi,

I don't think it matter much, as the CMS is storing session data too to use one or the other.

I tend to use $session = CRM_Core_Session::singleton(); but more often than not, it's to access an existing variable, not so store a new one.

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

awasson

  • I post frequently
  • ***
  • Posts: 230
  • Karma: 7
  • Living in a world of Drupal / CiviCRM
    • My Company: Luna Design
  • CiviCRM version: Latest
  • CMS version: Drupal 6/7/8
  • MySQL version: 5.x
  • PHP version: 5.3.x
Re: CRM_Core_Session... Should I set my session variables to CRM_Core_Session
December 22, 2012, 11:36:53 am
Hi xavier,

Yes, I was using $session = CRM_Core_Session::singleton(); to access data about the current user and thought that since it is a proper object with protected data, it might be a good place as any to store my session data as well. I just wasn't sure about whether it would go against "best practices" when it comes to extensions. I'm just storing simple numbers.

Thanks,
Andrew   
My CiviCRM Extension Workshop: https://github.com/awasson

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Discussion »
  • Extensions (Moderators: mathieu, totten, kasiawaka) »
  • CRM_Core_Session... Should I set my session variables to CRM_Core_Session

This forum was archived on 2017-11-26.