Where do I add that`?
Main Topics
Browse All TopicsHi,
I dont know if this is possible or not, just want to be sure.
I have a upload form which is located at "domain.com" this form link to a subdomain of the domain "fileserver.domain.com".
And the "form page" I create a session that I need to get at the subdomain - is this possible, or is the session terminated when it leave the main domain?
The subdomain is added to my dns cluster.
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I'll give an example of a simple session control, that supports (cookies being on or off and sub domains). The example is to just show how easy it is to write your own session control that you can plugin to database or just use PHP storage. The control just makes sure that the session is passed if cookies or if not cookies enabled by the user!
<?
define ( 'SESS_NAME', 'ms' ); // the session name
define ( 'SESS_TOUT', 900 ); // session time out (cookie time out)
// check all the places the session could be, if not found, make a new one!
! isset ( $_COOKIE[SESS_NAME] ) && isset ( $_GET[SESS_NAME] ) && ! empty ( $_GET[SESS_NAME] ) ? session_id ( $_GET[SESS_NAME] ) : ( ! isset ( $_COOKIE[SESS_NAME] ) ? session_id ( md5 ( uniqid ( microtime () ) ) ) : null );
session_name ( SESS_NAME );
session_start ();
// are they logged in ? ( update cookie time )
if ( isset ( $_SESSION['local'] ) )
{
// try to set the cookie, we don't care if we can set
// because we will handle the session via a url if it
// does not exist or can not be set!
@setcookie ( SESS_NAME, session_id (), ( time() + SESS_TOUT ), '/', '.domain.com', 0 );
}
// build the url session add control
// a safe session trans_id control
/*
* ADD_A is used in FORM ACTIONS -> <form action='script.php<?=ADD_A
* ADD_A is also used in links that don't contain a query -> <a href='service_page.php<?=A
*
* ADD_B is placed in links that already contain a query -> <a href='service_page.php<?=A
*/
define ( 'ADD_A', ( ! isset ( $_COOKIE[SESS_NAME] ) ? '?' . SESS_NAME . '=' . session_id() : '' ), true );
define ( 'ADD_B', ( ! isset ( $_COOKIE[SESS_NAME] ) ? '?' . SESS_NAME . '=' . session_id() . '&' : '?' ), true );
// do stuff...
?>
ms!
Business Accounts
Answer for Membership
by: mensuckPosted on 2006-01-15 at 07:17:04ID: 15704674
Yes, you can do that. But this is where using the default session control does not allows work. I good idea to be sure the session is avalible accross domains is to create your own session related cookies, that control where the session is valid!
if you want the session to be valid accross sub-domains then use a DOT before the main domain name when setting the session cookie!
define ( 'SESS_NAME', 'ms' ); // the session name
define ( 'SESS_TOUT', 900 ); // session time out (cookie time out)
@setcookie ( SESS_NAME, session_id (), ( time() + SESS_TOUT ), '/', '.domain.com', 0 );
See the DOT before domain.com in the set cookie function
ms!