Hi, i'm doing a wordpress plugin that add some data from angularjs/json on each post
in the json angularjs request i have to pass the session id
i've found this code to set it

$id = session_id();

but i don't know where to put it becouse if i add it in the function that print the data below the article post session_start() gives error where do i have to put the session_id() in a wordpress plugin? thank you for help

2 Years
Discussion Span
Last Post by surferbloggy

you can add it on your plugin or theme function. I don't have any time to actually check for my answer. However, I did this long time ago and this is how much I can recall.

Warning! *Please check the wordpress codex for validity of my wordpress syntax and make sure they are not deprecated. I did this long time ago and I haven't check on their updated documentation.
For example, if I have a plugin called veedeoo_plug and I want to register the PHP session for this plugin in wordpress global space, then I would code it something like this.

function my_session(){



## we need to hook the above function with the wordpress.


After adding the codes above, check if there are any errors. If no errors you can assign the session as you would assign them on regular php

$_SESSION['your_session'] = 'foo_bar';

for the add_action reference, please read here.

Votes + Comments
nice work!
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.