Sessions and subdomains

I’ve done it like this now, but it would be great if i could share sessions between different applications. Looks like i have to write an extension for that because i want the forum to be able to stand on it’s own.

Yes. The main problem with modules is, that modules can’t work on their own. They need a parent application. Besides that… in theory modules can be nested, but my experience with that is very bad, there is no sufficient documentation about this, only one ‘tip’ in the docs.

The Yii commandline shell can’t handle nested modules. This is one of the things i hope the devs will take a look at. Think about it. When this truely works (and with! the commandline tool too), applications can be endless deep.

In short, i want 3 features for my applications:

  • Easy to add a subdomains for and be able to share sessions

  • Every app (forums, backend) must support modules

  • Yiic shell support

In CWebUser:


	public function getStateKeyPrefix()

	{

		if($this->_keyPrefix!==null)

			return $this->_keyPrefix;

		else

			return $this->_keyPrefix=md5('Yii.'.get_class($this).'.'.Yii::app()->getId());

	}

Yii::app()->getId():




	public function getId()

	{

		if($this->_id!==null)

			return $this->_id;

		else

			return $this->_id=sprintf('%x',crc32($this->getBasePath().$this->name));

	}



As you can see the application name is used to generate the unique id. You may override getStateKeyPrefix() so that the generated key-prefix doesn’t include Yii::app()->getId(). Than it should work. Note that Yii::app()->getId() is used in other parts of Yii as well (like CCache to generate unique cache key accross applications).

Still I see no need for different application names (judging from the skeleton you uploaded). Also modules are a good way to go like already noted. If you need help for modules just open new thread or send me pm. It’s really easy.

// Also note if you don’t want a “parent-module”, you can just create a blank application and then add the modules. So the blank application doesn’t have controllers and so on. It only serves the core features like configs and models.

You are right.

I’ve reorganized the application like here.

Pointed [font=“Courier New”]backend.domain.loc[/font] also to the web-root. Nothing special here, but i changed the bootstrap file a bit ;)

http://www.yiiframework.com/doc/cookbook/63/#c1276

Yes i’m going to work with modules. :). Thank you for your spare time.

I tried implementing your solution but only logout works on localhost.