これは、Cookieを実装しない私のソリューションの一般的な考え方です。実際には質問に答えていないことはわかっていますが、Valentinと話し合って(コメントを参照)、これを考えてみると、Cookieは適切な設計上の選択ではなく、多くの問題が発生しやすいことがわかりました。代わりに、Joomlaコンテンツプラグインを作成することにしました。これにより、コンテンツ内の{showappwithuser}タグのペアが検索され、タグペア内のURLを指すiframeに置き換えられます。例えば:
{showappwithuser}http://www.somewebsiteapp.com{/showappwithuser}
これは、 http://www.somewebsiteapp.com? uid= joomlausernameを指すiframeに置き換えられます。。これにより、情報が受け入れ側のアプリに渡され、そのアプリはそれを使用して必要な処理を実行できます。完全なコードは以下のとおりですが、ほとんどすべてがハードコーディングされているという点でまだ少し不格好です。コンテンツ作成者が幅、高さ、スクロールバーアクセスなどのiframe設定を選択できるように、パラメーター処理を追加する必要があります。また、uidパラメーターの暗号化を統合して、アプリケーション間で情報が難読化されるようにする予定です。これは実際には多くの異なる方向に進む可能性があり、正しく記述されていれば、Joomla以外のアプリケーションをJoomlaサイトにシームレスに統合するための優れたプラグインになる可能性があります。この方法を使用して他のパラメーター情報をアプリに送信する可能性も無限にあります。楽しみ!
<?php
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
// import the general plugin file of Joomla!'s library
jimport( 'joomla.plugin.plugin' );
// hook into the plugin framework
class plgContentShowAppWithUser extends JPlugin
{
// the core code to create an iframe and set it's URL source
// with the logged in user name from Joomla
public function onContentPrepare($context, &$row, &$params, $page = 0)
{
$starttriggerpos = strpos($row->text, "{showappwithuser}");
$iframeurl = "";
if ($starttriggerpos !== false)
{
$endtriggerpos = strpos($row->text, "{/showappwithuser}");
if ($endtriggerpos !== false)
{
$iframeurl = substr($row->text, $starttriggerpos+17, $endtriggerpos-$starttriggerpos-17);
if (!JFactory::getUser()->guest)
{
$username = trim(JFactory::getUser()->username);
if (strlen($username) > 0)
{
$row->text = '<iframe src="' . $iframeurl . '?uid=' . $username . '"' . ' frameborder=0 scrolling=auto width=725>This application requires a browser that supports iframes.</iframe>';
}
else
{
$row->text = "Your web site login could not be determined. Please correct this and try again.";
}
}
else
{
$row->text = "You must login to the web site in order to access this content.";
}
}
}
}
}