Jump to content

unsetting session array


sKunKbad

Recommended Posts

//I have a session array :
$_SESSION['OfferListingId'][0]='bob';
$_SESSION['OfferListingId'][2]='ted';
$_SESSION['OfferListingId'][3]='mary';
$_SESSION['OfferListingId'][4]='jill';
$_SESSION['OfferListingId'][5]='spike';

//and when I try to unset the entire array using:
unset($_SESSION['OfferListingId']);

//it doesn't work. Why not?

Link to comment
https://forums.phpfreaks.com/topic/50478-unsetting-session-array/
Share on other sites

neither of those worked, but actually, i dont want to unset them, i want to completely delete them, so I was thinking something like this would work:

array_splice($_SESSION['OfferListingId'],0);

but it doesn't. I don't know what the heck is going on!

	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); 
header('Cache-Control: no-store, no-cache, must-revalidate'); 
header('Cache-Control: post-check=0, pre-check=0', FALSE); 
header('Pragma: no-cache'); 

[b]session_start();[/b]
//I have a session array :
$_SESSION['OfferListingId'][0]='bob';
$_SESSION['OfferListingId'][2]='ted';
$_SESSION['OfferListingId'][3]='mary';
$_SESSION['OfferListingId'][4]='jill';
$_SESSION['OfferListingId'][5]='spike';
echo "<pre>";
echo "Before";
print_r($_SESSION['OfferListingId']);
//and when I try to unset the entire array using:
unset($_SESSION['OfferListingId']);
echo "<pre>";
echo "After";
print_r($_SESSION['OfferListingId']);
[b]exit;[/b]
//it doesn't work. Why not?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.