• Resolved theoni

    (@theoni)


    Hello!
    First of all, very nice plugin!
    I have an issue though..I want to use session_start(); inside the widget but it seems that it is not recognized for some reason…I say that because I used var_dump to see if php code above and after it is executed – var_dump of the code above session_start(); returns non-empty array, while var_dump/print_r of $_SESSION; returns Array ( )…

    When I execute the whole code outside wordpress, just via php pages, all run smoothly…

    Is it not supported?
    Can we dubug this?

    Thank you in advance!

    https://wordpress.org/plugins/php-code-widget/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Because the normal behavior of session_start() is to use cookies, and cookies have to occur before any output is printed, then no, you really can’t use session_start in a widget like that.

    Thread Starter theoni

    (@theoni)

    Hello,
    thank you for your reply.
    We want to set up a subscription process.
    So basically, I will have to see how wordpress handles sessions so as to get the data from a wordpress variable, right?

    Plugin Author Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    WordPress does not use PHP Sessions at all. If you want to use them, best to write a plugin for that.

    Thread Starter theoni

    (@theoni)

    Thanks for your reply!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘php widget- can I use session_start(); ?’ is closed to new replies.