WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Please help! PHP session still not working (2 posts)

  1. gommez
    Member
    Posted 1 year ago #

    hello,

    i've tried adding session to my wordpress install.
    but still not working.

    added the following in functions.php

    function ses_init() {
    if (!session_id())
      session_start();
    }
    add_action('init','ses_init');

    also added "_SESSION" in "wp-includes/load.php"
    $no_unset = array( '_SESSION', 'GLOBALS', '_GET', '_POST', '_COOKIE', '_REQUEST', '_SERVER', '_ENV', '_FILES', 'table_prefix' );

    but these codes work in my localhost wp not in remote
    what do i need to do for sessions to work in remote server?
    i have no idea what to do next.

    any help is very much appreciated.
    thanks in advance

  2. gommez
    Member
    Posted 1 year ago #

    this is fixed.
    if you had the same problem with me as mentioned above.
    try this:
    *make sure you only have 1

    if (!session_id())
      session_start();
    }

    in your wp files/themes/plugins
    i just found out that my ajax.php file also contains that code
    i also have one in functions.php. removing it from ajax.php
    did the trick.

Topic Closed

This topic has been closed to new replies.

About this Topic