Re:Re: [PHP-WIN] Has anyone gotten session_destroy() to actually work on Windows?
| From: | Michel Laine | Date: | Fri, 14 Dec 2001 11:40:17 +0000 |
| Subject: | Re:Re: [PHP-WIN] Has anyone gotten session_destroy() to actually work on Windows? | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-10901@lists.php.net to get a copy of this message | ||
David Ayres wrote:
> Thanks Egil,
>
> But I've tried everything and can not get it to work. I also can't get it
Obviously not ;-)
...since you cannot get it to work you must have left out some poswsible
combination that will work - right?.
>
> to instantiate a session until I print the Session variables once to the
To instantiate a session you should only have to do a session_start() at the
beginning of a page.
To register a session variable you use the session_register('my_var') - after
your session_start() line.
To use registered session variables on a page you have to do a session_start()
before any variables can be used (i.e. on every page).
To end a session you first have to issue a start_session(), possible a cleanup
(as one prevoios poster suggested) of the variables and then a
session_destroy().
The session_start() line must be issued before any HTML output/echo/header line
in the code!.
>
> HTML Page, then the session finally works. It's really strange (I just wish
> it were as stable as .Net). Thanks for your feedback...
>
It's simple.
It should be simple.
this is the code that i am currently using on an dev-intranet-logout
(logout.php) page:
<?php
// Destroy the current session
$refpage = $HTTP_SERVER_VARS['HTTP_REFERER'];
session_start();
session_destroy();
?>
<center>
You have logged off the intranet.
<BR>
<a href="<?PHP echo "$refpage"; ?>">Go back</a>
</center>
As another poster put it: "works like a charm".
If you still have a problem making it work - is there any possibility that it is
caused by some PHP.INI settings?
+++
I'm a newbie myself - so don't flame me if anything in the above is false -
instead write a note to this discussion group and correct me.
I don't know a thing about .Net - but if you want it simple i believe that PHP
(still) is your right choice.
--
Michel Laine