Remove your session_start() and at the beginning of your functions.php put this:
if (!session_id()) {
session_start();
}
For use from a plugin use this:
function register_session(){
if( !session_id() )
session_start();
}
add_action('init','register_session');
Related Posts:
- Customizing subject in comment notification e-mails
- Save user total active time after login in wordpress [closed]
- Plugin Hook: Get posts
- Remove H1 title in admin post edit screen
- What are the differences between WPINC and ABSPATH?
- How can I see all the actions attached to an “add_action” hook?
- Problems with autoloading classes via sp_autoload_register / maybe interfering WP-specific autoloader
- How to remove duplicate sub-menu name for top level menu items in a plugin?
- When can you get current page ID and initialize hooks right after?
- category_name not working (not showing up in sql query debug)
- How to save the values of checkbox to the register setting?
- Using require_once in a Plugin?
- How can I make my custom shortcode work in a Custom HTML Widget?
- Edit plugin without hooks in functions.php
- WP showing “warning: call_user_func_array()”, What to do?
- How to Loop Plugin Option Field Set?
- Find out what is using PHP sessions in WordPress
- Making plugin unique to not conflict with plugins with the same name
- How to find out if option exists but is empty?
- Using the ‘draft_to_publish’ hook (post status transition)
- SESSION in WordPress Plugin Development
- Update Multiple Post Meta for the Same Post In One call?
- Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)
- WordPress Hook that will run when media file deleted
- How to pass JavaScript variable to PHP in wordpress widget?
- Unable to add admin notice on plugin activation
- How To Ignore a Filter On Applying Filter the Content In a Function
- Saving Plugin settings to the database
- How do I configure WordPress to talk to a Microsoft SQL Server database?
- WordPress widget / plugin….fields not appearing in my widget
- Add CSS animation as Preloader to WordPress
- Rename existing old uploaded images containing accented French characters (not during upload)
- How to list the Hooks and order of execution in current loading page? [duplicate]
- Good tools for locating hooks in a wordpress page/admin interface/blog post?
- How to Create a Directory in a Plugin Folder?
- Errors while using ajax from external wordpress page
- Pass A Value From Outside To A Plugin Variable
- shortcode doesn’t work
- Built in admin ajax hooks?
- Failed to invoke other hook from the init hook
- Ajax call doesn’t work in frontend but it’s working in backend (when I’m logged in)
- How can I add a custom meta value on file upload?
- Adding dynamic section to WordPress
- How can I filter blog name?
- Create plugin that works in background
- Checking for user role in a custom plugin
- Fatal error: Class not found in
- Is it possible to add an action to the currently running action?
- Deleting images through upload folder, but not deleting from media library
- Custom Shipping method not showing in checkout
- Showing Notifications While Activating Plugin
- HELP: Integrating WP with raw PHP code once published button is hit
- OOP: Display warning and deactivate the plugin if PHP version is less than 5.4
- Loading class files via autoload method
- Determine plugin name from within plugin_action_links filter
- WordPress plugin installation
- How to prevent action in ajax request, when in admin side?
- merging an array to an existing array using add_filter
- I would like to use create a function in my custom plugin to tell WP to use a different header
- template_redirect not being called when using ajax
- Getting media library popup in custom plugin admin page
- Create or Update thousands of woocommerce products via PHP
- send_headers don’t work on wordpress multisite
- jQuery function didn’t work in my plugin
- Placement of Code in Plugin for hooking `save_post`
- publish_post plugin hook doesn’t always pass $post->post_content
- What are the benefit in adding hook in the init() hook?
- Reposition Woocommerce Message
- Sanitizing, Validating and Escaping in WordPress (Plugin)
- add_action in functions.php, do_action in plugin?
- Escape when echoed
- Scope for PHP Variables Assigned in functions.php or a plugin
- How to correctly detect accessing wp-content/uploads?
- Plugin exceeds memory limit
- How to initialize something in unit test before the init hook being called?
- add action for displaying posts using a shortcode
- Write to / remove from default .htaccess file from plugin?
- ‘wp_login’ action hook not working with wp-login.php file
- Update Option Error: Notice: Undefined index
- Plugin Development sqlite or WordPress’ database
- How to cancel WordPress’ action/filter when using OOP with anonymous callback
- WordPress Plugin Page is Loading in Admin Content Container Instead of Separate Page
- Woocommerce attatch files and custom input meta to cart items and then to order
- How to add usermeta for existing users when user profile is updated
- wp_head filter not executed inside custom class
- redirect logged users to custom front-end insetad of wp-admin
- How to fetch WordPress Gallery Images to a Custom Post Type?
- Add 2 links in between the navigation using the Breadcrumb Navxt plugin hook
- Remove custom menu pages for admin users
- Custom uploader – Upload files and save link into database
- Implement Google SSO in custom plugin
- Unable to use correctly composer autoload in plugin file
- I have issue to retrive post thumbnail with rest api
- Custom block based off core block using filter
- Custom plug-in issues
- Custom Search Function in WordPress Returns No Results
- Call to undefined function create_function() – PHP 8.2
- can not serialize and insert data from custom form
- Custom page template from plugin does not work with pre-installed themes in WordPress 6.6.1
- Custom Dynamic Tag in Elementor not showing image