/    Sign up×
Community /Pin to ProfileBookmark

How to clear the data inside session variables?

guys, how am i going to clear data inside session variables?
in every page, i put a

session.start();

so i will be able to access the data that I stored inside the session variables.
Now what I want to have a “RESET” function (button, link, etc) that will
clear the data inside the session variables.

I tried using a “RESET” link inside “home.php”
<a href = “reset.php”>RESET</a>

inside “reset.php”..
<?php
session.close();
header(‘home.php’); // this is the page where I initialize the session
?>

inside “home.php”..
<?php
session.start();
.. // some code where I store data inside the session
?>
<a href = “reset.php”>RESET</a> // reset link

What do you think guys? I closed the session and started it again? I should get a session different from the previous one, right?

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJun 27.2005 — [code=php]
# unset all session variables:
$_SESSION = array();
[/code]

For more info, see http://www.php.net/manual/en/function.session-destroy.php and in particular study Example 1 carefully.
×

Success!

Help @Det7 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 6.2,
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: @meenaratha,
tipped: article
amount: 1000 SATS,

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

tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,
)...