Is it safe to use $_POST directly in my plugin instead of using admin-ajax.php to receive data from ajax?

First, everyone doesn’t say that. Everyone says to use admin-ajax.php for ajax, which is it’s meant for, not form submissions precisely. It’s not as popular and well covered, but there is actually different endpoint for form submission — admin-post.php. The reasons are, however, same. What you cannot do in your plugin is reliably load WordPress … Read more

WP_Session not acting with AJAX

I think in your code you must add this line for ajax acting jQuery.ajax({ type : ‘POST’, url : ‘<?php echo admin_url(‘admin-ajax.php’); ?>’, data : { action : ‘vg_show_post_id’, post_id: $post_id, data-id: true }, ),