Jump to content

[SOLVED] Cookies


tomtom

Recommended Posts

Hey. Right. I've just figured out why stuff haven't been working on my site. It's because, I login at mysite.com/delta

 

The login script is located at /delta/login.php

 

And creates a cookie. The cookie can only be read in /delta though. Not on the rest of my site, such as /deltasite

 

My code for creating the cookies are...

 

<?php
setcookie("id", $user[id],time()+86400, "/");
setcookie("pass", $user[password],time()+86400, "/");
?>

 

Cheers for the help guys. Thanks :) Need any extra info? Just ask :P

Link to comment
https://forums.phpfreaks.com/topic/109164-solved-cookies/
Share on other sites

Yeah, the cookie is created OK.

 

How do I retrieve it? Like this.

 

I have a script called config.php or something like that under /deltasite

 

Both /delta index and /deltasite index include it.

 

In that script, the code is...

 

 

<?php
$link = mysql_connect(all of this is correct);
mysql_error();
mysql_select_db (site_delta);

if($_COOKIE[id]){
$connect = mysql_query("SELECT * from `users` WHERE `id`=$_COOKIE[id]");
$logged = mysql_fetch_array($connect);
}
?>

 

It's very strange indeed. :P I'm not sure if it's just for me or for everyone. But it's just weird. Because, I have scripts in deltasite index that rely on $logged info...and work. :S

Link to comment
https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559962
Share on other sites

Yeah. Because I went on the settings and viewed the cookies and their info, both set. And it does work for /delta but not /deltasite.

 

I'm really baffled by this. I don't understand why it shouldn't work. It could be something to do with my internet connection but surely there should be a way around this. lol

Link to comment
https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559973
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.