/    Sign up×
Community /Pin to ProfileBookmark

still struggling with sessions…

I have my session working apart from one thing…

The output from the var_dump($_SESSION); at the bottom of the code after adding two items is:

array(1) { [“lightbox”]=> &array(2) { [0]=> string(5) “29576” [1]=> string(5) “29509” } }

How do I remove just one ID number? Is it an array I am trying to delete rather than a session variable?

Any help would be greatly appreciated!!

PAGE 1:

<form action=’lightbox.php’ method=’POST’>
<input type=’hidden’ name=’img’ value=”<?php echo($id)?>”>
<input type=’submit’ value=’Add to Lightbox’>
</form>

PAGE2:

<?php
foreach ($_POST as $field => $id)

$_SESSION[‘lightbox’][] = $id;

foreach($_SESSION[‘lightbox’] as $id)
{
echo “Image ID: $id<br><br>n”;
}

echo “<br><br>”;

var_dump($_SESSION);

echo “<br><br>”;

?>

to post a comment
PHP

0Be the first to comment 😎

×

Success!

Help @katiepie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...