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
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
Share on other sites

I got someone else to try it, and it works for them. Whereas for me it doesn't? What could this be down to? Ip conflict? I have 2 ips I think lol

 

But as I said... it works on /delta but not /deltasite FOR ME, but for others, it does.

Link to comment
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.