bs0d |
Subject: "re: hmm?
cookies"
Posted: @ 2:44 am on Dec 05 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
make sure the
cookie is being
set in your
login code
would be 1st
step
|
Viewed: 19,836 Times | |  |
ki |
Subject: "re: hmm?
cookies"
Posted: @ 3:31 am on Dec 05 2006
|
|
|
 Member #: 204 Rank: User - (50) Since: 09/16/06 Posts: 53 From: Florida
|
it does. I
use
Code:
$joined
=''.$_POST['
username'].'[
]'.md5($_POST[
'password']).
'';
setcookie('log
in_cookie',
$joined,
2147483647,
'/',
'.www.tragical
.net'); <
br>
it works fine
|
Viewed: 19,831 Times | |  |
bs0d |
Subject: "re: hmm?
cookies"
Posted: @ 12:53 pm on Dec 05 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
How do you
know it set the
cookie? Test it
by something
like,
if(isset($_COOK
IE['login_cook
ie'])) {
echo('cookie
WAS set');
} else {
echo('cookie
NOT set');
}
Edited at 12:58:53 pm on 12/05/06
|
Viewed: 19,820 Times | |  |
ki |
Subject: "re: hmm?
cookies"
Posted: @ 8:19 pm on Dec 05 2006
|
|
|
 Member #: 204 Rank: User - (50) Since: 09/16/06 Posts: 53 From: Florida
|
ok I tested it
it like this
Code:
<?
if($_GET['p']
==
"test&qu
ot  {
if(isset($_COOK
IE['login_cook
ie'])) {
echo('cookie
WAS set');
} else {
echo('cookie
NOT set');
}
}
if($_GET['p']
==
"set&quo
t  {
$joined =
"ki[]&qu
ot;.md5('passw
ord');
setcookie('log
in_cookie',
$joined,
2147483647,
'/',
'www.tragical.
net');
}
if($_GET['p']
==
"del&quo
t  {
setcookie('log
in_cookie',
"",
time()-21474836
47, '/',
'www.tragical.
net');
}
?>
ok I didnt even
set it at first
then I got
cookie WAS set,
then I delete
it, then I try
it again, I get
the same thing.
so whats up?
|
Viewed: 19,806 Times | |  |
bs0d |
Subject: "re: hmm?
cookies"
Posted: @ 4:07 am on Dec 06 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
You might need
to refresh
after the
cookie is set?
The cookie is
set in
login.php, then
header()
redirects to
the home page.
In your
page_header
code of home
page check if
cookie was
set.
also explore php.net/setcoo
kie
and read
through that a
bit and through
the comments. I
have it setup
exactly as the
tutorial is,
and it seems to
work for
everyone.
Also consider
re-examining
your
page_header
code and login
code to make
sure nothing
was left out
and that the
variables match
up to ones you
use.
|
Viewed: 19,795 Times | |  |
ki |
Subject: "re: hmm?
cookies"
Posted: @ 6:19 pm on Dec 06 2006
|
|
|
 Member #: 204 Rank: User - (50) Since: 09/16/06 Posts: 53 From: Florida
|
some reason
this stuff
still isn't
working
|
Viewed: 19,777 Times | |  |
bs0d |
Subject: "re: hmm?
cookies"
Posted: @ 6:59 pm on Dec 06 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
post in
seperate code
boxes your page
header code and
your login code
|
Viewed: 19,773 Times | |  |
ki |
Subject: "re: hmm?
cookies"
Posted: @ 9:44 pm on Dec 06 2006
|
|
|
 Member #: 204 Rank: User - (50) Since: 09/16/06 Posts: 53 From: Florida
|
header
Code:
date_default_t
imezone_set('E
ST');
require_once('
config.php');<
br />
session_start(
);
if
($_SESSION['lo
gged_in'] != 1
&&
isset($_COOKIE[
'login_cookie
'])) {
list($user,
$pass) =
explode('[]',
$_COOKIE['trag
ical_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;;
}
login
Code:
|
Viewed: 19,763 Times | |  |
bs0d |
Subject: "re: hmm?
cookies"
Posted: @ 12:18 am on Dec 07 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
When you store
the cookie, you
use [] between
the username
and password. I
would change
that back to |
. So thats an
adjustment on
line 5 in your
page header,
and line 11 on
login.php. Also
on your
login.php on
line 12 where
you set the
cookie, take
the www out.
I dont know if
those changes
will make a
difference, but
right off the
top those are
variances in
your code
compaired to
the tutorial.
|
Viewed: 19,754 Times | |  |
ki |
Subject: "re: hmm?
cookies"
Posted: @ 1:59 am on Dec 07 2006
|
|
|
 Member #: 204 Rank: User - (50) Since: 09/16/06 Posts: 53 From: Florida
|
ah now I got
it, the [] is
the problem
with it all, It
turns out that
when firefox or
any other
browser for
that matter
wont read the
same as [] but
as the code
such as like
%59 or
something
|
Viewed: 19,748 Times | |  |
bs0d |
Subject: "re: hmm?
cookies"
Posted: @ 2:24 am on Dec 07 2006
|
|
|
 Member #: 1 Rank: Admin. - (1,505) Since: 02/06/05 Posts: 600 From: USA
|
Cool, so it
worked? I was
also affraid
php may try to
interpret [] as
an array
element or
something. We
use the | just
to seperate
username from
password so it
could be almost
anything. |
makes sense to
me. Hope you
got it working.
|
Viewed: 19,745 Times | |  |
ki |
Subject: "re: hmm?
cookies"
Posted: @ 5:37 am on Dec 07 2006
|
|
|
 Member #: 204 Rank: User - (50) Since: 09/16/06 Posts: 53 From: Florida
|
bs0d
said...
<
i>
Cool, so it
worked? I was
also affraid
php may try to
interpret [] as
an array
element or
something. We
use the | just
to seperate
username from
password so it
could be almost
anything. |
makes sense to
me. Hope you
got it working.
nvm now its not
working lol. it
decides to end
with the
session
>:O
///////////////
//////////
Nevermind about
that post.
It works, I
found out in
the frustration
of the cookie I
renamed one of
the cookie
explode to see
if there was an
error, now it
works 
Thanks.
Edited at 05:39:46 am on 12/07/06
|
Viewed: 19,737 Times | |  |
infinity000 |
Subject: "re: hmm?
cookies"
Posted: @ 11:20 am on Feb 19 2007
|
|
|
Member #: 281 Rank: User - (2) Since: 02/19/07 Posts: 2
|
I changed it
like this :
Code:
$joined
=''.$_POST['
username'].'[
]'.md5($_POST[
'password']).
'';
setcookie(&quo
t;login_cookie
",
$joined,
2147483647,
"/"
.'gm');
Code:
setcookie(&quo
t;login_cookie
","
", time()
- 60,
"/"
.'gm');
Edited at 11:28:57 am on 02/19/07
|
Viewed: 18,280 Times | |  |
Viewing Page: 1 of 1 |