Welcome to Dream.In.Code
Getting PHP Help is Easy!

Join 135,945 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,743 people online right now. Registration is fast and FREE... Join Now!




Php Cookie Problem!

 
Reply to this topicStart new topic

Php Cookie Problem!

Quik
18 Sep, 2002 - 08:58 AM
Post #1

D.I.C Lover
Group Icon

Joined: 6 Mar, 2001
Posts: 3,750



Thanked: 1 times
My Contributions
Ok, So i got a login script going, with cookies and all, so if you goto the login page while you already are logged in, it displays a message.

I go ahead, and post the SAME script on another page, in another file, and it won't retrieve the cookie!
The file is in another folder- but that shouldnt be the prob..

CODE

if (isset($HTTP_COOKIE_VARS["login"])) {
echo "You are already logged in | <a href='logout.php'>Logout</a>";
} else {}



Structure is:
dev/login/form.php
dev/poll/view.php

the form.php retrieves it fine. However the view.php dosnt. whats up?!
User is offlineProfile CardPM
+Quote Post

Quik
RE: Php Cookie Problem!
18 Sep, 2002 - 09:06 AM
Post #2

D.I.C Lover
Group Icon

Joined: 6 Mar, 2001
Posts: 3,750



Thanked: 1 times
My Contributions
OK..
So, I drag the 'Poll' folder into the 'login' folder, and it works.

Obviouslly this must be a security issue for only accepting cookie requests from 'x', but is there a solution around this?
User is offlineProfile CardPM
+Quote Post

Quik
RE: Php Cookie Problem!
18 Sep, 2002 - 09:14 AM
Post #3

D.I.C Lover
Group Icon

Joined: 6 Mar, 2001
Posts: 3,750



Thanked: 1 times
My Contributions
ok.. I figured it out


setcookie ("cookie1", "$val1", time()+3600, "/");

is the proper way of setting the cookie when you need to use it in the WHOLE website.

the "/" enables it to be accesed through your server
User is offlineProfile CardPM
+Quote Post

fyrestorm
RE: Php Cookie Problem!
19 Sep, 2002 - 08:13 AM
Post #4

D.I.C Lover
Group Icon

Joined: 4 Apr, 2002
Posts: 3,103



Thanked: 2 times
Dream Kudos: 228
My Contributions
QUOTE(Quik @ Sep 18 2002, 11:14 AM)
ok.. I figured it out


setcookie ("cookie1", "$val1", time()+3600, "/");

is the proper way of setting the cookie when you need to use it in the WHOLE website.

the "/" enables it to be accesed through your server

awsome knowledge quik, glad you figured that out on your own and shared it with us...now i can apply that knowledge to various projects...
User is offlineProfile CardPM
+Quote Post

Quik
RE: Php Cookie Problem!
19 Sep, 2002 - 09:17 AM
Post #5

D.I.C Lover
Group Icon

Joined: 6 Mar, 2001
Posts: 3,750



Thanked: 1 times
My Contributions
No problem- I based it on trial and error.

Note, When you wan't to delete the cookie, you have to have the same format as what you set it with, but of course with a time()-number .
User is offlineProfile CardPM
+Quote Post

fyrestorm
RE: Php Cookie Problem!
19 Sep, 2002 - 11:31 AM
Post #6

D.I.C Lover
Group Icon

Joined: 4 Apr, 2002
Posts: 3,103



Thanked: 2 times
Dream Kudos: 228
My Contributions
thanks for the note, i'll keep that in mind
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/1/08 08:49AM

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month