After running the code sniffer on Magento 2 extension got several warnings and that includes one warning saying "The use of function session_id() is discouraged". So what is the alternative to get the session_id in Magento 2 extension?

  • where you have used it?
    – Amit Bera
    Commented Jul 13, 2020 at 12:54
  • @AmitBera want to use while posting data to the third party API
    – Mehar
    Commented Jul 13, 2020 at 14:30

1 Answer 1


The principal is that you should be using Magento framework methods instead of php functions

For example


  • Great! Thanks man
    – Mehar
    Commented Jul 14, 2020 at 8:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.