Jump to content

Recommended Posts

I am trying to send a random number from my first page to my second page with a session. That works fine, but the reason I am sending this random number from my first page to my second page with a session; is because I have used it to set a cookie and I want my second page to check for the cookie. The cookie sets fine, but when I try to check for my cookie in my second page; it does not work.

 

Here Is The Code For My Second Page:

 

<?php
session_start();
?>
<html>
<head>
        
<title>Untitled</title>

</head>
<body>

<?php

$tta = $_SESSION['cookie'];
if (empty ($_COOKIE['$tta'])) {
echo "You Are Not Logged In";
}
else {
echo "Welcome Back To....";
}

?>

</body>
</html>

 

 

If I echo "$tta"; it produces the name of the cookie, but once I put "$tta" in the empty cookie validation; it is not recognizing the session variable.

 

Any one know why this is not working?

Well any way - I figured it out...........

 

<?php
session_start();
?>
<html>
<head>
        
<title>Untitled</title>

</head>
<body>


<?php

if (empty ($_COOKIE[''. $_SESSION['cookie'] .''])) {
echo "You Are Not Logged In";
}
else {
echo "Welcome Back To....";
}

?>

</body>
</html>

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.