I'm having a hard time getting these cookies to load correctly.
Problem:
First of all, after the user's info checks out, it is time to put the info into cookies, then go to the login_good.php page.
Because there has already been output to the browser at this time, the cookies cannot be set within this page.
Therefore, I use a javascript redirect to a small php page which will send the cookies:
The $_POST data referred to here is correct at this point.
The redirect sends the user (and the $_GET data) to the login_good_pre.php page:
Obviously, the cookies are not being set properly, or are not being retrieved properly*. I have checked this with 3 computers using 2 different OS's (linux, win2k, winXP) and 7 different browsers (konqueror, firefox1, firefox2, IE6, IE7, opera, galleon), all of which I have made sure are set up to accept all cookies. None of these configurations work.
Why won't the cookies work?
Surely it is some simple, stupid mistake I've made, because I'm as inexperienced with cookies as possible.
*I looked in the browser's cookie cache, and the cookies are not there (although others are). This proves that the cookies are not being received by the browser properly.
Code for me to search for this thread later:
lsfjselkmfsihyslfnm
Problem:
First of all, after the user's info checks out, it is time to put the info into cookies, then go to the login_good.php page.
Because there has already been output to the browser at this time, the cookies cannot be set within this page.
Therefore, I use a javascript redirect to a small php page which will send the cookies:
The $_POST data referred to here is correct at this point.
| Code: |
|
$_POST['username'] = stripslashes($_POST['username']); //echo "redirect and cookies"; echo "<script language='javascript'>"; echo "window.location='login_good_pre.php?username=" . $_POST['username'] . "&password=" . $_POST['pass'] . "'"; echo "</script>"; |
The redirect sends the user (and the $_GET data) to the login_good_pre.php page:
| Code: |
|
<?php $hour = time() * 4; //This file prepares the cookies for login_good.php, then redirects to it. setcookie('EqDr_story_ID', $_GET['username'], $hour); setcookie('EqDr_story_key', $_GET['pass'], $hour); //header("Location: login_good.php"); //temporarily disabled so I can troubleshoot this page. echo $_GET['username']; //The echoed result here is correct echo "<br>"; echo $_GET['password']; //The echoed result here is correct echo "<hr>"; echo $_COOKIE['EqDr_story_ID']; //No result from echo echo "<br>"; echo $_COOKIE['EqDr_story_key']; //No result from echo //echo time() . "<br>"; //correct //echo $hour; //correct ?> |
Obviously, the cookies are not being set properly, or are not being retrieved properly*. I have checked this with 3 computers using 2 different OS's (linux, win2k, winXP) and 7 different browsers (konqueror, firefox1, firefox2, IE6, IE7, opera, galleon), all of which I have made sure are set up to accept all cookies. None of these configurations work.
Why won't the cookies work?
Surely it is some simple, stupid mistake I've made, because I'm as inexperienced with cookies as possible.
*I looked in the browser's cookie cache, and the cookies are not there (although others are). This proves that the cookies are not being received by the browser properly.
Code for me to search for this thread later:
lsfjselkmfsihyslfnm
