473,657 Members | 2,420 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 14901
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?9onl ine.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_global s being 'ON'.

unset( $_SESSION['variable'] );

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

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

The above will work with register_global s on & inside a function

[/quote php.net]

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

The above will not work with register_global s 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_glob als'))); echo '<p>';
if ((int)ini_get(' register_global s') === 1)
ini_set('regist er_globals', false);
session_cache_l imiter();
session_start() ;
print_r(ini_get ('register_glob als'))); echo '<p>';
[/PHP]

In PHP 4.3.6 with register_global s ON this happens:

1
It successfully turned off register_global s, 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_global s 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
1725
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 get_to_post(); // $_POST = $_GET foreach ($tempIDArray as $tempID) unset($_SESSION); print_r("POST: "); print_r($_POST); print_r("<P>"); extract($_POST, EXTR_SKIP); foreach ($_POST as $key => $val) $GLOBALS = $val; unset($_SESSION);
3
2241
by: Phil Powell | last post by:
class LoginSessionGenerator extends MethodGenerator { function LoginSessionGenerator() {} /** * Logout * * @access public */ function &logout() { // STATIC VOID METHOD
0
1595
by: Phil Powell | last post by:
<?php class LoginSessionGenerator { /** * Logout * * @access public */ function &logout() { // STATIC VOID METHOD
2
13164
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 and structure it? Let's say that I have nested arrays a, b & c, I would like some output
3
2070
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 counter never advances beyond 1! // HANDLE THE PART WHERE THE STUDENT INFORMATION WILL BE UPDATED OR SEARCHED if (is_array($_POST) && @sizeof($_POST) > 0) {
2
1419
by: comp.lang.php | last post by:
if ($forceDownload) { // HANDLE FORCED DOWNLOAD $dlGen =& new DownloadGenerator($fullFilePath); $negativeIndex = $dlGen->generateForceDownloadHeaders(); $willDeleteTemp = $dlGen->getSession('willDeleteTemp'); if (!$dlGen->isSuccessful) $errorArray = $dlGen->getErrorArray(); if ((int)$negativeIndex !== -1 && $willDeleteTemp) { if ($dlGen->getSession('album')) { $locationPath = "${'tmp' . ucfirst($dlGen->getSession('section'))...
25
3313
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, when I press back button, I get to the page that says "Page has Expired" but Firefox does not do this. I think it's something to do with sessions not properly unset or something like that but I haven't been able to figure it out. I am
6
1628
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: __utma 238121498.423365001.1211713664.1212127389.1212130222.30 __utmz 238121498.1212127389.29.4.utmcsr=hffar.com|utmccn=(referral)| utmcmd=referral|utmcct=/ __utmc 238121498 cprelogin no
25
1907
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" class="style26" id="name" value="<?php echo $row_rs_mas; ?>" size="50"/> <------ appear automatic when I insert the matric_no.. my problem is how to make it automatically appear when insert matric_no
0
8395
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8826
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7330
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4155
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4306
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1615
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.