Jump to content

Recommended Posts

use mysql session then

create a mysql table, named sessin

when someone open a session, store to the mysql database (set timestamp)

when certain time, clean the sessions

then u can achieve it across domain, even across server session

 

choose a mysql server that u can connect use a ip, or domain

None of that is necessary.

 

If you A) read the session handling section of the php.net documentation - http://us2.php.net/manual/en/book.session.php (i.e. you are trying to incorporate sessions into your script, you must read the documentation for what you are doing to be affective at doing it) you will B) find that there is a session.cookie_domain setting that will allow the session cookie to match all sub-domains/host-names of your domain.

I put this:

 

session_set_cookie_params(0, '/', '.edited-out.com');

session_start();

 

Didn't do anything though =/

 

The handling section just said~:

 

   To implement database storage, or any other storage method, you   will need to use session_set_save_handler() to   create a set of user-level storage functions. 

Don't see how that helped at all.

 

Okay i tried this aswell in my php.ini file:

<?php
// The domain for which the cookie is valid.
session.cookie_domain = .edited-out.com
?>

 

still not working, user logs in on main domain then when they go to subdomain the session is not set anymore even though i still have session start =/

Based on what you have stated you are doing, setting the session.cookie_domain (as long as it is being set the same before every session_start()) should work. What have you done to troubleshoot what it is doing?

 

Are full php error_reporting/display_errors on so that you would know if the session is starting without errors (i.e. would sessions work at all in both pieces of code even without changing sub-domains)? Is the session cookie being sent to your browser and is the value in the session cookie the the same that session_id() shows that php is using on each page?

 

Show us the two different URL's you are using. xxxxx out any sensitive information but don't change any of the other parts of the whole urls that you are using.

Well here it is, in more detail:

 

www.xxxxxx.com/login.php

 

this script has:

<?php
session_start();  
?>

 

Before i edited the php.ini i had:

<?php
session_set_cookie_params(0, '/', '.edited-out.com');
session_start();  
?>

 

 

And when user logged in successfully  $_SESSION['Current_User'] = $UserID; (lets say 1)

 

Now a user clicks a link which takes them to www.test.xxxxxx.com/index.php

 

This has:

<?php
session_start();  
?>

 

Before i edited the php.ini i had:

<?php
session_set_cookie_params(0, '/', '.edited-out.com');
session_start();  
?>

No offense intended, but did you actually use 'edited-out.com' or did you use 'yourdomain.com'?

 

If your main url is www.MyDomain.com and your sub-domain is www.test.MyDomain.com, then I think the setting would be:

 

session_set_cookie_params(0, '/', '.MyDomain.com');

 

I've never used this, but I want to make sure you set the right value.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.