Jump to content

Recommended Posts

why aint this working??

 

<?php
                                if ($_COOKIE['watch_id']){
                                    $cookie = $_COOKIE['watch_id'];
                                    $cookie_query = mysql_query("SELECT * FROM user WHERE cookie='$cookie'");
                                    if (mysql_num_rows($cookie_query) >= 1){
                                    ?>
                                    <li><a href="/index.php">Home</a></li>
                                    <li><a href="/cpanel.php">C-Panel</a></li>
                                    <li><a href="/logout.php">Logout</a></li>
                                    pass
                                    <?php   
                                    }
                                    if (mysql_num_rows($cookie_query) <= 1){
                                    ?>
                                    <li><a href="register.php">Register</a></li>
                                    <li><a href="#" onclick="OPEN_login();">Login</a></li>
                                    <li><a href="index.php">Home</a></li>
                                   fail1
                                    <?php
                                    }
                                }
                                
                                if(!$_COOKIE['watch_id']){
                                ?>
                                <li><a href="register.php">Register</a></li>
                                <li><a href="#" onclick="OPEN_login();">Login</a></li>
                                <li><a href="/index.php">Home</a></li>
                                fail2
                                <?php
                                }
                                ?>

 

i have checked in the browser and the cookies match but it always echos fail2 which means that this line is returning false:

 

if ($_COOKIE['watch_id']){

 

i have tried using isset but that didnt help either!

 

any help?

Link to comment
https://forums.phpfreaks.com/topic/250807-cant-get-this-cookie-to-work-properly/
Share on other sites

Either the cookie isn't set properly and/or PHP isn't being given the cookie by the web server.

 

Since I don't see print_r($_COOKIE); anywhere, I'm going to assume you haven't actually checked if it exists.

 

If it does exist, ensure the value is what you'd expect.

 

If it doesn't, there's an issue with your cookie or your web server. Verify that your client is actually sending the cookie along with the request.

it doesnt show what im expecting however when i look in the chrome cookie manager my website is listed twice

 

as domain.com and www.domain.com

 

and its the domain.com cookies that are echoing.

 

how can i set my cookie to domain.com instead of www.domain.com

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.