/    Sign up×
Community /Pin to ProfileBookmark

Logout script

This is almost embarassing, but… whatever. So, I’m developing this site, right, and it uses sessions for user validation. Now, the user has to have the option of logging out, so I just wrote a tiny script that’d do just that:

[code=php]$_SESSION = array();
session_destroy();[/code]

Hey, it works! But the problem is that after that is done, I want to redirect the user back to the main the page so that the session data is updated and the user can see he is logged out. Is there any way to accomplish this without the use of the header() function or HTML metas (’cause the script is included in the middle of the main page, not at the beginning)?

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@WedvichauthorFeb 28.2005 — Okay, okay, stupid me who doesn't test before I post... Problem solved. I didn't think using metas was possible outside the <head> tags, but I was wrong. Anyway, thank you for letting me waste your time! ?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYFeb 28.2005 — the header function reloads the page anyway, doesnt it?
Copy linkTweet thisAlerts:
@LiLcRaZyFuZzYFeb 28.2005 — Mr. Co-avatar-pimper!
Copy linkTweet thisAlerts:
@DaiWelshFeb 28.2005 — [i]Originally posted by Wedvich [/i]

[B]Okay, okay, stupid me who doesn't test before I post... Problem solved. I didn't think using metas was possible outside the <head> tags, but I was wrong. Anyway, thank you for letting me waste your time! ? [/B][/QUOTE]


I very much doubt it is valid html though, better to move the logout function to the top of the script so you can use header() or use outbut buffering functions to hold content until you have decided whether they are logging out.
×

Success!

Help @Wedvich 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.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

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