Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums

Go Back   Code Forums > Application and Web Development > PHP

Reply
 
LinkBack Thread Tools Display Modes
Old 08-24-2004, 06:50 AM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
cookie users across sub-domains?

is there any way to read a cookie from different subdomains?

the problem is that i want to do some fun stuff with subdomains and codenewbie, however i'm not sure that i can have cookies read between subdomains.
__________________
Mike
sde is offline   Reply With Quote
Old 08-24-2004, 06:54 AM   #2 (permalink)
sammy
Code Monkey
 
sammy's Avatar
 
Join Date: Jun 2004
Location: Brooklyn/Rochester
Posts: 53
sammy is on a distinguished road
Send a message via AIM to sammy
Sharing cookies among all subdomains
As explained earlier, cookies are not shared among subdomains or between the domain and the subdomain. In order to set cookies accessible by all subdomains, use the following techniques:

1. While writing the cookie, set the cookie domain to ".domain.ext" so that it applies to all subdomains.
2. If the cookie domain is set to ".domain.ext", it will not be accessible by a user who types in the address without the www before the domain (i.e. http://domain.ext). Therefore, redirect all requests without www to http://www.domain.ext.

There are some reported problems with the above approach. It is safe to set the default cookie with no domain specified and then set another one with domain as ".domain.ext". In this case there is no need for the redirects. However, remember that session cookies are set by the web server software and you may not have control over how the cookie domain is set.

hope that helps
__________________
sammy is offline   Reply With Quote
Old 08-24-2004, 10:49 AM   #3 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
yeap thanks.
PHP Code:
<?
setcookie
($key,$value,time()+3600,"/",".codenewbie.com");
?>
__________________
Mike
sde is offline   Reply With Quote
Old 08-25-2004, 01:50 PM   #4 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
PHP Code:
<?
$amount 
5;
$type Chocolate_Chip;

eatCookies($amount,$type);
?>
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 08-25-2004, 01:52 PM   #5 (permalink)
Admin
$_['Your_Mom'];
 
Admin's Avatar
 
Join Date: May 2002
Location: Santee
Posts: 627
Admin is on a distinguished road
yum
__________________


Urban Clothing
Admin is offline   Reply With Quote
Old 08-25-2004, 02:08 PM   #6 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,505
sde is on a distinguished road
lol
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Trojan targets user's financial information redhead Code Newbie News 0 07-01-2004 05:52 AM
New domains '.mobi' and '.xxx' under consideration sde Code Newbie News 0 03-22-2004 07:05 AM
jail ssh to users home directory? sde Linux / BSD / OS X 5 01-10-2004 10:09 AM
Database Users Keen on Linux 2.6 Kernel sde Linux / BSD / OS X 0 05-19-2003 02:01 PM


All times are GMT -8. The time now is 02:17 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting