User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 456,196 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,924 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2765 | Replies: 1
Reply
Join Date: Aug 2003
Location: Steamboat Springs, CO
Posts: 82
Reputation: himerus is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 0
himerus's Avatar
himerus himerus is offline Offline
Junior Poster in Training

Help Problems with session_unregister and / or unset()

  #1  
Jul 4th, 2004
Hey all! Sorry I haven't been around much lately. Hope things are well cscgal! :cheesy:

I'm working on a new function for the admin control panel of my site.

When a user logs in, it checks to see if it's a normal user, and then if not, checks to see if it is the administrator (me).

I've set up a select menu that allows me to log in as the "normal user" after I've logged in as admin. That part works fine, and I am logged in with admin permissions, yet, am viewing the control panel as the normal user would.

I have created a "switch" script that should unset the session vars that are registered for the normal user, which are company_id and cname, which hold obvious values.

However, when I use the script to unset the variables to either return to admin only, or switch to a new company, for some reason the session vars aren't being cleared, but it only happens on the page in which I registered the variables to begin with. The variables are registered in the header include, so this can occur on almost any page of the admin section...

Here is the contents of my "switch" script, which should unset the variables, and return me to the main page of the control panel...

Most of my session functions are fairly simple, so I'm totally confused on what may be wrong...

[PHP]
<?
session_start();
global $valid_user; // username
global $company_id, $cname;

// I added this section to make sure it wasn't caching the page
header("Cache-Control: no-cache");
header("Cache-Control: post-check=0,pre-check=0");
header("Cache-Control: max-age=0");
header("Pragma: no-cache");
// End

session_unregister("company_id");
session_unregister("cname");
unset($cname, $company_id, $_SESSION['company_id'], $_SESSION['cname']);
header ("Location: $acp_location");
?>
[/PHP]

Any Ideas???

Thanks in Advance!!!
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2002
Location: Long Island, NY
Posts: 1,134
Reputation: samaru is just really nice samaru is just really nice samaru is just really nice samaru is just really nice 
Rep Power: 12
Solved Threads: 5
Colleague
samaru's Avatar
samaru samaru is offline Offline
a.k.a inscissor

Re: Problems with session_unregister and / or unset()

  #2  
Jul 7th, 2004
Just a quick question: are you trying this on a Windows server or Linux? I had a similar problem where I could not unset the session variables. I tried everything and posted on every forum I could think of. Nothing worked. I moved the app to a Linux server and it worked. Strange. Maybe a fault with the version of PHP I was using.
_.:: my websites ::._
blog @ www.samaru.net * engi No Jutsu @ www.narutorp.net * portfolio @ shinylight.com
deviantART: inscissor
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb PHP Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 3:48 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC