SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Trying to implement session_name to keep variables from mixing

    I have a website and backend tool that both use $_SESSION[firstName] and sometimes the data mixes. So I did some research and came up with session_name, but it's not working for me. The admin session variable is not being shown on the page I created to show session variables. Do I have this setup correctly?


    Backend tools page:
    session_name("Tools");
    include 'startSession.php';
    $_SESSION['admin'] = "Yes";



    startSession.php page:
    session_name("Tools");
    session_start();
    header("Cache-control: private"); // IE 6 Fix.



    Session variable display page:
    session_name("Tools");
    session_start();
    echo '<pre>';
    print_r($_SESSION_NAME['Tools']);
    echo '</pre>';
    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Drop session_name. Just use nested arrays...as so:
    Code:
    $_SESSION = array( 'site' => array(), 'Tool' => array() );
    $_SESSION['Tool']['something'] = 'whatever';
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •