473,406 Members | 2,377 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,406 software developers and data experts.

Cookie

I have a website that is accessible (at least from our local campus
network) by four different ways:

1) the full url: http://campuslaan37.student.utwente.nl/
2) the short url: http://campuslaan37/
3) an alias: http://cam37.student.utwente.nl/
4) the short alias: http://cam37/

I use cookies to save and set some preferences etc. However, if you
surf from e.g. (1) to (3), it is treated as an entirely different
site, and nothing that was stored in the cookie applies anymore.

Is there a way to set the cookie, such that it immediately applies
to all the possible URLs to access the site?

Thanks in advance,

--
Daan
Jul 17 '05 #1
3 1864
*** Daan wrote/escribi (Tue, 17 Aug 2004 11:54:48 +0200):
Is there a way to set the cookie, such that it immediately applies
to all the possible URLs to access the site?


setcookie() has a parameter called domain ("the domain that the cookie is
available"). Then it explains:

"To make the cookie available on all subdomains of example.com then you'd
set it to '.example.com'. The . is not required but makes it compatible
with more browsers. Setting it to www.example.com will make the cookie
only available in the www subdomain."

This doesn't exactly apply to your case since your URLs don't have a "tail"
in common. However, I suppose you could use setcookie() to set the cookie
several times, one for each domain. You could write a function to make it
easier:

function mysetcookie($name, $value='', $expire='', $path='', $secure=''){
$aliases=array(
'campuslaan37.student.utwente.nl',
'campuslaan37',
'am37.student.utwente.nl',
'cam37'
);

foreach($aliases as $domain){
setcookie($name, $value, $expire, $path, $domain, $secure);
}
}

Be aware that I didn't test the code. It probably needs to handle empty
parameters differently.

--
-- lvaro G. Vicario - Burgos, Spain
-- Questions sent to my mailbox will be billed ;-)
--
Jul 17 '05 #2
On Tue, 17 Aug 2004 12:10:16 +0200, Alvaro G Vicario wrote:
*** Daan wrote/escribió (Tue, 17 Aug 2004 11:54:48 +0200):
Is there a way to set the cookie, such that it immediately applies to
all the possible URLs to access the site?


setcookie() has a parameter called domain ("the domain that the cookie is
available"). Then it explains:

"To make the cookie available on all subdomains of example.com then you'd
set it to '.example.com'. The . is not required but makes it compatible
with more browsers. Setting it to www.example.com will make the cookie
only available in the www subdomain."

This doesn't exactly apply to your case since your URLs don't have a
"tail" in common. However, I suppose you could use setcookie() to set the
cookie several times, one for each domain. You could write a function to
make it easier:


For security reasons, browsers will not set cookies which do not match a
different domain than where the page was served. In this case, you might
get away with setting the cookie's domain to ".student.utwente.pl" which
will include campuslaan37 and cam37.

HTH,
La'ie Techie
Jul 17 '05 #3
"Lie Techie" wrote:
On Tue, 17 Aug 2004 12:10:16 +0200, Alvaro G Vicario wrote:
*** Daan wrote/escribió (Tue, 17 Aug 2004 11:54:48 +0200):
Is there a way to set the cookie, such that it immediately
applies
to all the possible URLs to access the site?
setcookie() has a parameter called domain ("the domain that the

cookie is
available"). Then it explains:

"To make the cookie available on all subdomains of example.com then

youd
set it to .example.com. The . is not required but

makes it compatible
with more browsers. Setting it to www.example.com will make the

cookie
only available in the www subdomain."

This doesnt exactly apply to your case since your URLs

dont have a
"tail" in common. However, I suppose you could use setcookie()

to set the
cookie several times, one for each domain. You could write a function to
make it easier:


For security reasons, browsers will not set cookies which do not

match a
different domain than where the page was served. In this case, you
might
get away with setting the cookies domain to
".student.utwente.pl" which
will include campuslaan37 and cam37.

HTH,
Laie Techie


If nothing else works, you can always redirect the subdomain to the
real domain. There is a slight delay for the user and some refershing,
but at least your cookie info are available to the user.

--
http://www.dbForumz.com/ This article was posted by author's request
Articles individually checked for conformance to usenet standards
Topic URL: http://www.dbForumz.com/PHP-Cookie-ftopict140317.html
Visit Topic URL to contact author (reg. req'd). Report abuse: http://www.dbForumz.com/eform.php?p=470472
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
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">...
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: Wysiwyg | last post by:
After a server created cookie is processed on the client I want it removed, cleared, or expired in the javascript block but have been unable to do this. If I set a cookie value in the server code...
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...
6
by: kelvlam | last post by:
Hello all, I'm still a bit new with JavaScript, and I hope the guru here can shed some light for me. It's regarding handling cookie and the case-sensitive nature of JavaScript itself. My...
2
by: kelly.pearson | last post by:
Is this a bug? I am trying to write a cookie that can be accessed by various .Net applications on our domain. However, whenever I add the domain property to the cookie, no errors get thrown but...
5
by: cbhoem | last post by:
Hi - I am trying my hand at python cookies. I'm confused about a few things though. Do the python cookies get written to a cookies text file? I have simple code below -- I see the cookie in...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing,...

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.