Click to See Complete Forum and Search --> : setcookie on IIS


patricktan
04-26-2001, 04:09 PM
Hi All!

Found this on the archives. I couldn't find a satisfactory solution response though. I'm encountering the same problem on IIS 4 and PHP4 when I migrated from Apache and PHP4.

setcookie("username", "pat", 0);
setcookie("password", "pat", 1);

works on the linux version but nothing comes out on the $username and $password in the IIS version.

I'm wondering if I should tweak IIS 4.0 or the php.ini.

Hope you guys can help. Thanks!

--------
Author: Michael R
Date: 2000-06-28 09:26:12
Subject: setcookie problem on new server
The problem is, I've been developing this site for a couple of months on NT (PHP3.0.16 & IIS). I use cookies to track the user. In preparation for moving the site to the production server, I tested it on a Linux system with PHP4 & Apache (don't know what version). On both the development and test servers, the cookies worked fine. Now, on my development server, it doesn't work on IE! The production server is PHP3 and Apache.

The code for setcookie is:

// Begin Code

setcookie("user_name", $user, (time()+TIME_OUT), "/vet/", "www.myserver.com", 0);
setcookie("user_hash", $hash, (time()+TIME_OUT), "/vet/", "www.myserver.com", 0);
setcookie("user_id", $arArray["uID"], (time()+TIME_OUT), "/vet/", "www.myserver.com", 0);

echo "" .
"" .
"";

exit;

// End code

The variables are set correctly prior to calling setcookie, TIME_OUT is a constant defined to 1200 (20 minutes). I have also tried this without the last three parameters, that didn't work. Also with "/" as the directory. Would different versions of Apache and PHP have anything to do with it? I don't see what else would be causing the problem.

Anon
04-27-2001, 08:04 PM
Hi,

You might try looking at you php.ini file (win32 install of php) and look for these lines and set as so. On win32 the directories have to use windows file locations, unlike on Linux where this value is usually set to "/"

session.save_path = c:\temp
session.cookie_path = c:\temp

c:\temp can be any other directory you wish to store cookies session files.

This works for me on win32 apache, IIS am not so sure about.

Rey

patricktan
04-30-2001, 11:56 AM
It's still not working though.( Here's the session part of my .ini file. Can you check it out if everything's in order? Thanks!


[Session]
session.save_handler = files ; handler used to store/retrieve data
session.save_path = c:\phptemp ; argument passed to save_handler
; in the case of files, this is the
; path where data files are stored
session.use_cookies = 1 ; whether to use cookies
session.name = PHPSESSID
; name of the session
; is used as cookie name
session.auto_start = 0 ; initialize session on request startup
session.cookie_lifetime = 0 ; lifetime in seconds of cookie
; or if 0, until browser is restarted
session.cookie_path = c:\phptemp ; the path the cookie is valid for
session.cookie_domain = ; the domain the cookie is valid for
session.serialize_handler = php ; handler used to serialize data
; php is the standard serializer of PHP
session.gc_probability = 1 ; percentual probability that the
; 'garbage collection' process is started
; on every session initialization
session.gc_maxlifetime = 1440 ; after this number of seconds, stored
; data will be seen as 'garbage' and
; cleaned up by the gc process
session.referer_check = ; check HTTP Referer to invalidate
; externally stored URLs containing ids
session.entropy_length = 0 ; how many bytes to read from the file
session.entropy_file = ; specified here to create the session id
; session.entropy_length = 16
; session.entropy_file = /dev/urandom
session.cache_limiter = nocache ; set to {nocache,private,public} to
; determine HTTP caching aspects
session.cache_expire = 180 ; document expires after n minutes

Anon
07-09-2002, 09:51 AM
I am unable to run cookie on IIS Server can any one help me to run cookies on IIS.

pot