473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unset($_SESSION['var']) fails

PHP:
unset($_SESSION['mainDisplay']);

In my original environment (PHP 4.3.2) this line will delete the
session variable 'mainDisplay'. But in the testing environment (PHP
4.3.6) the variable persists even after unset() is called.

Is there some special setting in PHP that can allow a session to
persist even if you attempt to delete it? I am only able to delete the
session variable upon closing the browser and rebooting computer.

Thanx
Phil
Jul 17 '05 #1
3 14883
Phil Powell wrote:
PHP:
unset($_SESSION['mainDisplay']);


<?php
session_start();

if (isset ($_SESSION['mainDisplay']) ) {

$_SESSION['mainDisplay'] = array();

}
?>

HTH,
Best regards,
Sebastian
--
The most likely way for the world to be destroyed,
most experts agree, is by accident.
That's where we come in; we're computer professionals.
We cause accidents.
--Nathaniel Borenstein
Jul 17 '05 #2
apologies for top-posting, i just need to get this rant out of the way
first:

sebastian - please make sure you quote the message to which you
replying in such a way as to make any further comments
understandable... for this reason i've inserted the original question
below, indented with pipes (|)
On Fri, 23 Jul 2004 19:50:34 +0200, Sebastian Lauwers
<?dacrashanddie?no?@?spam?9online.fr?> wrote:
|PHP:
| unset($_SESSION['mainDisplay']);
|
|In my original environment (PHP 4.3.2) this line will delete the
|session variable 'mainDisplay'. But in the testing environment (PHP
|4.3.6) the variable persists even after unset() is called.
|
|Is there some special setting in PHP that can allow a session to
|persist even if you attempt to delete it? I am only able to delete the
|session variable upon closing the browser and rebooting computer.

<?php
session_start();

if (isset ($_SESSION['mainDisplay']) ) {

$_SESSION['mainDisplay'] = array();

}
?>


and how is this meant to help?

the OP asked why his $_SESSION variable was not getting unset when he
asked it to ... assigning an empty array to the variable in question
is /not/ really a fix to the problem.

OP: RTM (http://www.php.net/manual/en/function.unset.php)

specifically the User Contributed Notes as follows:

[quote php.net]

andre at twg dot com dot au
07-Mar-2004 02:16

Only This works with register_globals being 'ON'.

unset( $_SESSION['variable'] );

The above will not work with register_globals turned on (will only
work outside of a function).

$variable = $_SESSION['variable'];
unset( $_SESSION['variable'], $variable );

The above will work with register_globals on & inside a function

[/quote php.net]

Jul 17 '05 #3
Herbie Cumberland <sp******@skipraider.com> wrote in message news:<sd********************************@4ax.com>. ..

The above will not work with register_globals turned on (will only
work outside of a function).

$variable = $_SESSION['variable'];
unset( $_SESSION['variable'], $variable );

------------------------------------------------------------------------------

The caveat being "Work outside of a function". Sorry, but this has to
occur within a class method, therefore, it doesn't work.

What I found that does work, however, has been denounced by the PHP
community at large, but not a single person can explain WHY this works
in spite of the fact that the Manual says you can't:

[PHP]
print_r(ini_get('register_globals'))); echo '<p>';
if ((int)ini_get('register_globals') === 1)
ini_set('register_globals', false);
session_cache_limiter();
session_start();
print_r(ini_get('register_globals'))); echo '<p>';
[/PHP]

In PHP 4.3.6 with register_globals ON this happens:

1
It successfully turned off register_globals, and I was able to, within
my class method, successfully delete the session variable:

[PHP]
unset($_SESSION['mainDisplay']);
[/PHP]

I even tested in the other server which is PHP 4.3.2 with
register_globals OFF and it works; turned it ON, it still worked!

Phil
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Phil Powell | last post by:
// CLIENT GLOBAL FUNCTION TO PARSE $_SESSION IF 'tempIDArray' IS SET function parseTempIDArraySession() { $tempIDArray = $_SESSION; $_GET = $_SESSION]; // RESET $_GET WITH SESSION ARRAY...
3
by: Phil Powell | last post by:
class LoginSessionGenerator extends MethodGenerator { function LoginSessionGenerator() {} /** * Logout * * @access public */ function &logout() { // STATIC VOID METHOD
0
by: Phil Powell | last post by:
<?php class LoginSessionGenerator { /** * Logout * * @access public */ function &logout() { // STATIC VOID METHOD
2
by: Baron Samedi | last post by:
I googled, but don't find anything... I have some pretty hairy arrays and when I var_dump() I get an unreadable mess. Surely someone has already written a function which will take a var_dump...
3
by: comp.lang.php | last post by:
I have a counter that evokes the "Three Strikes You're Out" rule.. if you make more than N mistakes it auto-resets to avoid flooding $_SESSION with attempt after attempt, etc. However, the...
2
by: comp.lang.php | last post by:
if ($forceDownload) { // HANDLE FORCED DOWNLOAD $dlGen =& new DownloadGenerator($fullFilePath); $negativeIndex = $dlGen->generateForceDownloadHeaders(); $willDeleteTemp =...
25
by: crescent_au | last post by:
Hi all, I've written a login/logout code. It does what it's supposed to do but the problem is when I logout and press browser's back button (in Firefox), I get to the last login page. In IE,...
6
by: oooobs | last post by:
Hello i have deficulty to deal with cookies in PHP my website is http://kal.am cookies not working and when i tried to print session array i got the following strange output: ...
25
by: azura | last post by:
<input name="matric" type="text" class="style26" id="matric" value="<?php echo $row_rs_mas; ?>" size="15" /> <------ this input that i insert those matric_no <input name="name" type="text"...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.