Jump to content

[SOLVED] Having Problem With Setting Cookie with Session Variable


phpQuestioner

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>

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.