tomtom Posted June 7, 2008 Share Posted June 7, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/ Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 I know it's supposed to be the same thing, but try doing ".blah.com" instead of "/" Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559956 Share on other sites More sharing options...
tomtom Posted June 7, 2008 Author Share Posted June 7, 2008 Nope Didn't work. Neither of them recognised it that time. Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559957 Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 and you know for sure that the cookie is being set right? And...how are you retrieving the cookie? Name spelled right in your script(s) in the other directory? etc... Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559959 Share on other sites More sharing options...
tomtom Posted June 7, 2008 Author Share Posted June 7, 2008 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. 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 Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559962 Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 and I know this is a dumb question, but to clarify: the condition is failing, and the query is not being executed, right? Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559967 Share on other sites More sharing options...
tomtom Posted June 7, 2008 Author Share Posted June 7, 2008 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. Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559969 Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 ermm...well, some browsers and versions of browsers require all parameters to be set in order to set a cookie, but you did say that the cookies are there...and you did make sure you have your browser set to allow sending cookie info? Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559971 Share on other sites More sharing options...
tomtom Posted June 7, 2008 Author Share Posted June 7, 2008 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 Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559973 Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 ha Well to be honest I'm kinda stumped now too. I'm about out of ideas myself :/ Have you tried it in a different browser? Like FF instead of IE or visa versa or Opera etc..? Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559974 Share on other sites More sharing options...
tomtom Posted June 7, 2008 Author Share Posted June 7, 2008 Hmm, it seems to work now! Thanks for your time and help Cheers Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559984 Share on other sites More sharing options...
.josh Posted June 7, 2008 Share Posted June 7, 2008 so...try anything new? change anything? Or do we file this under "X-Files" lol Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-559988 Share on other sites More sharing options...
tomtom Posted June 7, 2008 Author Share Posted June 7, 2008 Hahaha. Not that I know of So yes, X-Files Quote Link to comment https://forums.phpfreaks.com/topic/109164-solved-cookies/#findComment-560039 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.