bs0d |
Subject: "re: Logout not
working"
Posted: @ 4:43 pm on Dec 24 2005
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
|
Viewed: 33,028 Times | |  |
Ghezus |
Subject: "re: Logout not
working"
Posted: @ 5:12 pm on Dec 24 2005
|
|
|
 Member #: 125 Rank: user - (3) Since: 12/24/05 Posts: 3 From: Netherlands
|
Mmh ok now i
dont get any
error's... But
when i login it
does make the
changes on my
page (show
members menu)
But when i
click logout it
stay's in the
same way as
logged in...
Code:
<?
if($_SESSION['
logged_in'] ==
1) {
echo("<
;a
href='#'>P
rofile</a>
;
| <a
href='#'>R
SS
Favourites</
a> | <a
href='logout.p
hp'>Logout&
lt;/a> |
<a
href='#'>M
ore...</a>
;</p>&qu
ot;<img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
} else {
echo("<
;a
href='#'>L
ogin</a>
| <a
href='#'>M
ore...</a>
;"<img
src=http://www.
allsyntax.com/f
orums/images/sm
ilies/wink.gif
border=0>;
}
?>
[B]Current
logout.php<
br />
Code:
<?
ob_start();
$_SESSION['log
ged_in'] =
0;
setcookie('log
in_cookie',
"",
time() - 60,
'/',
'.http://local
host/TG/');
session_destroy
();
header("L
ocation:
http://localhos
t/TG/"  ;
?>
Edited at 05:18:04 pm on 12/24/05
|
| | | Viewed: 33,023 Times | |  |
bs0d |
Subject: "re: Logout not
working"
Posted: @ 5:59 pm on Dec 24 2005
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
hrm...
re-check
your header
code, somehow
the
$_SESSION['log
ged_in'] still
= 1. Gotta be
in the header
code somewhere,
because the
logout sets it
to zero, but
you said it
still says
your're logged
in even after
logout.
|
Viewed: 33,019 Times | |  |
Ghezus |
Subject: "re: Logout not
working"
Posted: @ 4:11 pm on Dec 28 2005
|
|
|
 Member #: 125 Rank: user - (3) Since: 12/24/05 Posts: 3 From: Netherlands
|
Still lost
:S.... I
checked my
header and even
tried the exact
one from the
tutorial...
Code:
<?
ob_start();
session_start(
);
require_once($_
SERVER['DOCUME
NT_ROOT'].'/T
G/db_connect.ph
p');
//check
cookie
if
($_SESSION['lo
gged_in'] != 1
&&
isset($_COOKIE[
'login_cookie
'])) {
list($user,
$pass) =
explode('[]',
$_COOKIE['logi
n_cookie']);
$qu =
mysql_query(&q
uot;SELECT
`user_password`
FROM `members`
WHERE
`username` =
'".addsl
ashes($user).&
quot;'"
if
(mysql_num_rows
($qu) == 1)
{
$passw
=
mysql_fetch_obj
ect($qu);
if
($passw->use
r_password ==
$pass) {
$_SESSION['log
ged_in'] =
1;
$_SESSION['use
rname'] =
$user;
$_SESSION['pas
sword'] =
$pass;
}
}
}
if(!isset($_SES
SION['username
']) &&
!isset($_SESSIO
N['password']
)) {
$_SESSION['log
ged_in'] =
0;
$user =
"Guest&q
uot;;
}
?>
|
| | | Viewed: 32,979 Times | |  |
bs0d |
Subject: "re: Logout not
working"
Posted: @ 6:06 pm on Dec 28 2005
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
i think the
cookie isnt
being
deleted... so
on your
logout.php
file, mess
around with:
setcookie('log
in_cookie',&q
uot;",tim
e()-60, '/',
'.http://local
host/TG/' );
maybe take the
/ out after
"/TG/&qu
ot;
you could
modify the
header code for
editing to see
whats going on,
thats a good
way to debug
and find the
problemes. try
doing something
like:
Code:
if(isset($_COOK
IE['login_cook
ie']))
echo("del
eting cookie
didnt
work" );
after you do
the
set_cookie()
with a -neg.
time in the
logout.php
file.
Edited at 02:40:18 am on 04/04/06
|
Viewed: 32,976 Times | |  |
Guest |
Subject: "re: Logout not
working"
Posted: @ 5:06 pm on Feb 06 2006
|
|
|
Unregistered
|
According to
Php.net:
"Cookies
must be deleted
with the same
parameters as
they were set
with."
I think the
problem is that
the script to
create the
cookie is
"setcooki
e('login_cooki
e', $joined,
2147483647,
'/',
'.craversdark.
com/practice2'
); "
but we're
deleting it
with:
"
setcookie('log
in_cookie',
"",
time() - 60,
'/',
'.craversdark.
com/practice2'
);"
when it should
probably be:
"
setcookie('log
in_cookie',
$joined, time()
- 60, '/',
'.craversdark.
com/practice2'
);"
Or something.
I'm playing
with it now.
-SeiferTim ::
http://www.crav
ersdark.com
|
Viewed: 32,866 Times | |  |
bs0d |
Subject: "re: Logout not
working"
Posted: @ 6:25 pm on Feb 06 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
ok good luck. I
noticed in my
code above it
should be
if(!isset() bla
bla...
works fine for
me the way its
setup. Let me
know what you
come up with
|
Viewed: 32,860 Times | |  |
Guest |
Subject: "After logout"
Posted: @ 6:49 am on Feb 20 2006
|
|
|
Unregistered
|
Hellow
everybody
after
logout.if i
click browser
back option
then it was
shown previos
static pages.so
how to block
this problem.
|
Viewed: 32,808 Times | |  |
bs0d |
Subject: "re: Logout not
working"
Posted: @ 2:40 pm on Feb 20 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
im not exactly
sure what
you're talking
about. could
you provide
more detail? I
dont think you
can keep it
from showing
prev. static
pages where you
was logged in.
If you were to
click a link,
it would ask
you to sign
back in again I
believe.
|
Viewed: 32,801 Times | |  |
Guest |
Subject: "re: Logout not
working"
Posted: @ 1:04 am on Apr 04 2006
|
|
|
Unregistered
|
Let me start by
saying this was
a wonderful
tutorial, but
as the people
above
mentioned. The
logout process
does not work
at all. The
cookie is not
destroyed. I
think it would
be better to
just use
sessions and
eliminate
cookies in this
tutorial and
accompanying
scripts since
the author does
not seem to be
able to fix
this.
Are cookies
included for
anything beside
remembering the
username in the
form? not sure.
but I think
sessions would
be enough to
make this
tutorial work,
unless bs0d
can figure out
why the logout
script
fails.
The way it is
now, even if
you close all
browsers, you
can still go
directly to the
secured content
without the
need to login,
which defeats
the whole
purpose of the
secured area.
|
Viewed: 32,585 Times | |  |
bs0d |
Subject: "re: Logout not
working"
Posted: @ 2:26 am on Apr 04 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
The tutorial is
written with
the option to
"remember
me" ergo
cookie
implementation.
So that when
you open a new
browser window
and visit the
site, you are
not required to
login. If you
would not like
that feature,
don't add it
or do not check
the
"remember
me"
checkbox.
The code
provided in the
tutorial has
worked for
many, and not
worked for few.
For those
having problems
with it, here a
few
alternatives to
try:
Code:
<?
setcookie(&quo
t;login_cookie
",
"",
mktime(12,0,0,1
, 1, 1970),
"/"
,
'.yoursite.com
');
//or
setcookie(&quo
t;login_cookie
" );
//or
setcookie('log
in_cookie',
"",
time() - 3600,
'/',
'.yoursite.com
');
Edited at 02:38:43 am on 04/04/06
|
Viewed: 32,579 Times | |  |
Guest |
Subject: "re: Logout not
working"
Posted: @ 4:42 am on Apr 04 2006
|
|
|
Unregistered
|
I have been on
this all day,
but finally got
it working.
Seems when I
used (false) as
the new value
in logout, that
did the trick.
Also I had to
replace the
time value
(2147483647)
you had in the
login.php with
time()+3600.
Also you need
to pay
attention to
the domain name
and sb
directory
values. They
have to be the
same as when
set.
The following
worked for me:
This is the
line that sets
cookie in the
login.php file:
---------------
---------------
---------
setcookie(&quo
t;login_cookie
",
$joined,
time()+3600,
"/secure/
",
"mydomain
.com" );
---------------
---------------
---------
This is the
line that
unsets it in
the logout.php:
---------------
---------------
---------
setcookie('log
in_cookie',
false, time() -
3600,
'/secure/',
'mydomain.com
');
---------------
---------------
---------
Edited at 11:46:46 am on 04/04/06
|
Viewed: 32,571 Times | |  |
Guest |
Subject: "re: Logout not
working"
Posted: @ 4:52 am on Apr 04 2006
|
|
|
Unregistered
|
oops, sorry
bs0d. Can you
please remove
my domain name
from the second
line (logout
code), I forgot
to remove it.
you can delete
this note
too.
Maybe I shoulda
registered
first lol
I hope the
above helps
someone.
Thanks.
|
Viewed: 32,569 Times | |  |
misterhaan |
Subject: "re: Logout not
working"
Posted: @ 6:10 pm on Apr 04 2006
|
|
|
 Member #: 5 Rank: Contributor - (214) Since: 02/11/05 Posts: 149 From: chair
|
time()+3600 is
only one hour
from whenever
they log in.
this means if
you are trying
to use the
'remember me'
feature and
someone comes
back tomorrow,
they have to
log in again.
on my site,
login cookies
are set to last
for 30 days
(2592000
seconds) so as
long as they
come back with
in a month they
will still be
remembered.
i haven't read
the tutorial
here though, so
feel free to
ignore me if
i'm not making
sense.
please note
that the above
post is likely
made up in its
entirety. |
Viewed: 32,560 Times | |  |
Guest |
Subject: "re: Logout not
working"
Posted: @ 9:28 pm on Apr 04 2006
|
|
|
Unregistered
|
Thanks bs0d for
fixing my post
above, much
appreciated.
misterhaan, I
agree with you
on the cookie
time, my whole
issue was not
the duration
but was the
logout process.
I needed that
when you click
logout you
should be
logged out
period. The
member area
that I am
setting up will
not be
frequently
accessed so the
duration of
cookie life was
not an issue
for me at all,
one hour is
more than is
needed to serve
the purpose.
but logout
works for me
now.
Thanks
everyone.
Joe
|
Viewed: 32,555 Times | |  |
Guest |
Subject: "What you use?"
Posted: @ 8:30 am on Apr 06 2006
|
|
|
Unregistered
|
What you
use?
windows xp
windows 2000
windows 98
windows 95
or other
---------------
Best regards
|
Viewed: 32,534 Times | |  |
Guest |
Subject: "re: Logout not
working"
Posted: @ 8:23 am on Apr 07 2006
|
|
|
Unregistered
|
Hi guyz,
for those who
are still
struggling
with:
Warning:
session_destroy
(): Trying to
destroy
uninitialized
session
change in
logout:
session_destroy
();
to:
@session_destro
y();
It works for me

|
Viewed: 32,517 Times | |  |
bs0d |
Subject: "re: Logout not
working"
Posted: @ 5:50 pm on Apr 23 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,510) Since: 02/06/05 Posts: 604 From: USA
|
I believe the
answer has been
resolved here.
Topic locked.
|
Viewed: 32,313 Times | |  |
Viewing Page: 1 of 1 |