473,385 Members | 1,888 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,385 software developers and data experts.

php cookie acting strangely

JnrJnr
88
Hi all, I have a little testing site where I want to test my problem.
The site has 3 pages:
Home, Account, Cart, and a menu to navigate to them.

What I do is:
On the Home page I set the cookie on submit button click. (the page refers to itself)
I then navigate to another page (Account) and check if the cookie is set. And it is.
Then I navigate to next page (Cart) and check if the cookie is set. And it is.

The problem:
When I go back to the page where I originally set the cookie, it always dispalys that the cookie has not been set.

Expand|Select|Wrap|Line Numbers
  1. setcookie('myCookie', 'Val', 0, '/', false); //this is done on Home page
  2. //The following is done on all pages...
  3. if(isset($_COOKIE['myCookie']))
  4. {
  5.   echo($_COOKIE['myCookie']);
  6. }
  7. else
  8. echo('not set');
Note: the problem occurs always from the page the cookie was set. Also this works fine in FireFox but not IE
Can anyone share some knowledge please?
Nov 2 '11 #1
4 1485
zorgi
431 Expert 256MB
You are checking in $_POST. Shouldn't you be checking within $_COOKIE

Expand|Select|Wrap|Line Numbers
  1. if(isset($_POST['myCookie']))
Nov 3 '11 #2
JnrJnr
88
Hi zorgi, you are right I made a mistake when I posted the question. (I will fix it)
It is suppose to be $_COOKIE[''] but it was still not working in IE.
I checked for help everywhere and tried a lot.
The only thing that I could make sense of is that I am using a local domain name (local server) to test and develop.
Apparently IE's cookies dont always function properly when using local servers.
So I installed IE 9 just for development purposes and its working fine now. Thanx for the code correction though!
Nov 4 '11 #3
zorgi
431 Expert 256MB
I just checked on my localhost with IE8 and it works fine.
Nov 4 '11 #4
JnrJnr
88
Thanks zorgi. As I said Im not entirely sure what the problem was.
Nov 4 '11 #5

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

Similar topics

2
by: Alex Kail | last post by:
I have a site that you can only gain access to if you are logged in. My sign in screen asks for your email address and password. If all checks out, I write out information to a cookie (Cookie 1). ...
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...
12
by: chrism | last post by:
Hello, I have a pop-up window that I would like to appear in front of the browser home page when a user opens IE. Problem is, I'd like it to never appear again if the user navigates back to the...
0
by: James | last post by:
I have a problem with the ide that, while I have a workaround, is still annoying. I have all the windows, help, properties, toolbox, call stack, watch, etc. set to auto-hide. There are times...
7
by: What-a-Tool | last post by:
How does the expire date work setting it server side with asp. I know with javascript setting it client side it will be set to the clients local time, and therefore expire when the clients local...
8
by: krisrajz | last post by:
Please observe the pages below: session1.asp <% Session("test")="TESTING" Response.Redirect "session2.asp" %> session2.asp
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...
4
by: socialism001 | last post by:
I'm trying to store a value in a cookie but its not working. Can anyone see what I might be doing wrong. Thanks, Chris ~~~~~~~~~~~~~~~~~~ <script language="javascript">...
1
by: CR1 | last post by:
I found a great cookie script below, but don't know how to make it also pass the values sent to the cookie, to a querystring as well for tracking purposes. Can anyone help? If there was a way to...
5
by: Kamran | last post by:
Hi, I am having problem using std::ifstream in my code under solaris. Everything works fine on linux but the same thing i.e. trying to read a binary file and fill in a struct result in complete...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.