The MU forums have moved to WordPress.org

setting a session variable (5 posts)

  1. pax2003
    Member
    Posted 16 years ago #

    I make php script, lets say test.php
    which is in the root folder with the rest of word press (same folder as wp-config.php)
    when i go to test.php i want to set $_SESSION["new_user"] = 'true';
    and redirect back to main page.

    but when i try to print out $_SESSION on the main page, 'new_user" is not there.

    the header of test is:
    [code]
    require( dirname(__FILE__) . '/wp-config.php' );
    wp_head();
    [/code]

    also, i seem to be able to use
    wp_setcookie($login->user_login,$login->user_pass,false);
    just fine.

    ps: the point of the script is to login a user using a external method. i alredy have a plugin the overrides the wpmu login function. is the only way to solve this is in that plugin?

    is there any way to do this the way i want to?

  2. pax2003
    Member
    Posted 16 years ago #

    Okay, I tried the same thing but used set_cookie in place of $_SESSION, and IT WORKED.

    but i do not want to use this method, because its unsecure.

  3. lunabyte
    Member
    Posted 16 years ago #

    Did you start the session?

  4. pax2003
    Member
    Posted 16 years ago #

    its started now thanks to this post and you
    http://wordpress.org/support/topic/107006?replies=6

    i assumed that wordpress had session already, which lead to my confusion.

  5. lunabyte
    Member
    Posted 16 years ago #

    Nope. WP doesn't automatically start the session, since all its authentication is cookie based, by default it doesn't need it.

About this Topic

  • Started 16 years ago by pax2003
  • Latest reply from lunabyte