Multiple php Session ID problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • EricKara
    New Member
    • Dec 2012
    • 1

    Multiple php Session ID problem

    I have two different session IDs ('reg_gen' & 'assess') for the same user to log in to different parts of the web site (containing several pages) with different passwords.
    I use the following code in the two php include file to switch between sessions(and website areas):
    php include file 1
    Code:
    <?php 
    session_id('reg-gen'); 
    session_start(); 
    session_destroy(); 
    session_id('assess'); 
    session_set_cookie_params(0); 
    session_start(); 
    and the rest of the code ................ 
    
    AND php include file 2 
    <?php 
    session_id('assess'); 
    session_start(); 
    session_destroy(); 
    session_id('reg-gen'); 
    session_set_cookie_params(0); 
    session_start(); 
    rest of the code..............................
    This works fine when I switch from one id to other without leaving the browser.
    When I close the browser and try to access a page in the same area of the web site as previously (with the same phpinlude file) I am not asked to login.
    I tried adding:
    Code:
    session_start(); 
    session_destroy();
    at the very beginning of each code above, but this time as I go from one page to other (with the same include file), each time I am asked to log in again.
    How can I destroy the previous session when leaving the browser, but only need to log in once on the first page instance of the same site area?
    Last edited by Rabbit; Dec 6 '12, 04:53 PM. Reason: Please use code tags when posting code.
Working...