473,320 Members | 1,916 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

COOKIE results in 'undefined index'

Markus
6,050 Expert 4TB
In the process of making a user registration page, and if a username and or email address is already in use i set a cookie then use header( ... to redirect the user back to the page with the form.
On the page with the form, i check to see if there is reason to echo the error (if isset $_GET['i']; .. )
And then echo the cookie out.
Hooooowever, it seems the cookie isn't being recognised or i'm just silly silly silly!
[php]
// setting the cookie
setcookie('Signup_Error', "Both username and email address have been taken! Please try again", time() + 3600);
header("Location: http://localhost/blog.mahcuz.com/?i");
[/php]

[php]
// retrieving the cookie
<?php
if(isset($_GET['i']))
{
$_error = $_COOKIE['Signup_Error'];
?>
<div id="error_signup">
<?php
echo $_error;
?>
</div>
<?php
}
?>
[/php]
All this does is throw an error: undefined index: Signup_Error

If i am to cancel the header redirect and just echo the cookie out as soon as it is set, it works fine
[php]
// setting the cookie
setcookie('Signup_Error', "Both username and email address have been taken! Please try again", time() + 3600);
echo $_COOKIE['Signup_Error'];
// header("Location: http://localhost/blog.mahcuz.com/?i");
[/php]

Living up to my name.. markusn00b
;)
Feb 16 '08 #1
1 8897
harshmaul
490 Expert 256MB
Hi,
I can't reacreate the exception your getting!
You could stick the $_COOKIE refernce in a if(IsSet()) thingy....

Expand|Select|Wrap|Line Numbers
  1. if(IsSet($_COOKIE['error_list'])) {
  2. echo $_COOKIE['error_list'];
  3. }
Or whatever.
Feb 17 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: Phil Powell | last post by:
Fourth attempt.. it fails now in login, I check by printing $_COOKIE and there is no value there! Guys, what on earth do I do about this???? Here is the code that sets the cookie: if...
2
by: Johnny | last post by:
Searched on google for any info relating to this before posting here but found none. I set up a web service using nusoap on apache php 4.3.8 on windows with error_reporting = E_ALL and had that...
4
by: Shannon Jacobs | last post by:
I'm doing some trivial surveys, and I want to know if the same user answers twice. Can't really know that, but at least I thought I could check for the same browser/computer combination by using a...
1
by: Display Name | last post by:
Used one of these canned scripts to set up a JS quiz but not before having used another canned PHP script for "Tell your friend about this Web page!" sort of thing. Now i've gotta integrate them;...
5
by: brettr | last post by:
When I reference document.cookie, there is a long string of key=value; pairs listed. I may have 100 hundred cookies on my hard drive. However, most only have one key=value pair. Does the...
14
by: Alec S. | last post by:
Hi, I'm using JavaScript and Cookies for some customization in a web page. There may be several values in the cookie with names that are not known at runtime. I need a way of deleting them. ...
9
by: Marco Krechting | last post by:
Hi All, I have a page with a list of hyperlinks. I want to save information in a cookie about the fact that I entered an hyperlink or not. When I click one of the hyperlinks I want this stored...
3
by: Fernando Rodríguez | last post by:
Hi, How do I test if a user has a given cookie? O:-) Thanks
10
by: DoomedLung | last post by:
Hey, I recently bought "The Javascript and DHTML Cookbook" by Danny Goodman. I'm at Chapter 1, part 1.9 "Reading and Writing Strings for Cookies" and was just interested in a utility function...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.