Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 6th, 2003, 07:08 PM
Registered User
 
Join Date: Nov 2003
Location: Melbourne, Victoria, Australia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default PHP Session passed to different sub domains

Hi there,

Could someone tell me how to pass a session cookie to different subdomains, without passing it in url.
Thanks in advance.

Regards,

Gera

Reply With Quote
  #2 (permalink)  
Old November 6th, 2003, 07:21 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You can configure PHP to use a specific cookie domain/path. I'm pretty sure (not positive, so this will require you to test it yourself) that if you only specify a host and tld (e.g. '.wrox.com'), the cookie will be available for all sub-domains.

For more info, read through the following manual pages (and the informative external links in them):
  http://www.php.net/session
  http://www.php.net/setcookie

The configuration option in PHP.ini that you want to look for is "session.cookie_domain".


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
  #3 (permalink)  
Old November 6th, 2003, 08:28 PM
Registered User
 
Join Date: Nov 2003
Location: Melbourne, Victoria, Australia.
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Nik,

I've already found the answer in php docs
http://www.php.net/manual/en/function.setcookie.php
will try it tonight.

Thanks for your help.
Regards,
Gera

Reply With Quote
  #4 (permalink)  
Old November 6th, 2003, 10:20 PM
Friend of Wrox
Points: 2,570, Level: 21
Points: 2,570, Level: 21 Points: 2,570, Level: 21 Points: 2,570, Level: 21
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: San Diego, CA, USA
Posts: 836
Thanks: 0
Thanked 0 Times in 0 Posts
Default

setcookie() is a function that allows you to set a cookie variable, but you have to be careful about messing up your original session variable. If PHP handles setting and retrieving your session ID in a cookie, you're probably best off configuring PHP to create a cookie that works across sub-domains.

If you have written your own session handling functions (and, in my opinion, it sounds like a good idea for your multi-domain site to do so, especially if each domain is on a different machine. If you're using the same database server to store all your session data, you can use a cookie to store the session ID for all sub-domains, and each server uses the same session handling functions and database server to access that user's session.

If I'm not making sense, let me know.


Take care,

Nik
http://www.bigaction.org/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
I need help with php variable passed to perl... nriv08 Beginning PHP 0 October 9th, 2008 12:54 PM
Keep session between different domains CenturiMan ASP.NET 2.0 Professional 0 March 21st, 2006 10:19 AM
Session Error in PHP Randhy MySQL 8 December 17th, 2004 07:49 AM
Can't display input variable passed on to php code mespejo Beginning PHP 2 November 25th, 2003 03:32 PM
form data not passed to php keng BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 2 September 4th, 2003 09:15 AM



All times are GMT -4. The time now is 01:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.