I cannot understand this. Plz help!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

I cannot understand this. Plz help!

Post by Joe »

I have been doing some expeimentation with cookies lately and I have came to a huge hault with the subject. When I try to create a small cookie showing the username from the previous page it doesn't show when I check my cookies through javascript in the URL.

<?php
$username1 = $_POST['username'];
setcookie("username", $username1, time()+36000);
?>

Is the post method way out here or am I doing something else wrong here.


Regards



Joe 8O
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

can you please post how you are showing the cookie.
im not sure what you mean by "I check my cookies through javascript in the URL.", please elaborate.
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

...

Post by Joe »

I mean by typing, javascript:alert(document.cookie); in the URL to view the cookie. Sorry for not explaining it the first time but i thought you would have known. So is there any chance of a little help on this?

Regards



Joe 8)
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

try this:

Code: Select all

<?php
setcookie("username", "bobmando", time()+36000);
?>
one less error factor to worry about!
User avatar
Joe
Forum Regular
Posts: 939
Joined: Sun Feb 29, 2004 1:26 pm
Location: UK - Glasgow

no!

Post by Joe »

Ya but that only uses the one username. I want to make it so im posting the username from one form to another if you know what i mean!

Regards


Joe 8)
toms100
Forum Contributor
Posts: 119
Joined: Wed Feb 26, 2003 10:29 am
Location: Bristol,UK

Post by toms100 »

yes, but does that work?
if it does, then your problem lies not with the cookie, but with the form submission!
Post Reply