/    Sign up×
Community /Pin to ProfileBookmark

Resetting session variables…

Ok… so I have this contact form I am working on. Right now it’s in the debugging phase.

I have assigned required fields and ensured they are filled in.
I have checked to make sure the email address is “somewhat” valid.
I have made error messages to display only if a message is assigned to the error global variable.

MY QUESTION, yes I have one!

Since my error messages are global using sessions, when I make a mistake they show up and tell me “Fill in the…” and once I fill in the fields correctly and then get my “Thanks alot…” message, how do I get that error message to go away if I return back to the page before I close my browser. Because if I navagate away from the “Thanks…” message and then go back to the contact page – the last error message still shows up. How can I fix this.

Yes, that was long-winded but…

Do I create a variable to check if sessions are there and reset them if they are? I guess maybe I could at the end of the success message since everything is being sent and good.

I don’t know if it makes a difference, but all my code is on one page that POST to itself.

Thx

to post a comment
PHP

2 Comments(s)

Copy linkTweet thisAlerts:
@bokehAug 19.2005 — Use unset($_SESSION['key']);

Or maybe after you have sent the thank you page you may unset() the session array and session_destroy().
Copy linkTweet thisAlerts:
@rch10007authorAug 19.2005 — I think I got it!

I was trying to use $_SESSION = array();

BUT it was in the wrong if ()!!!!

figures! LOL

thx
×

Success!

Help @rch10007 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,
)...