Im developing web plugin with FireBreath and I'm pretty newbie in this area. I have so far developed quite complex plugin API class (with registered methods, properties and some other variables and structs). I'am loading it onto page using javascript and default
object id="plugin0" type="application/x-myapp> tag.
But now I need to redirect to another html page and I need to keep all my previously filled variables from previous page. With the same model with OBJECT tag I think I created another instance of my plugin, because all variables were undefined. So my quiestion is how to keep one instance of plugin and make it accessible in multiple html pages?
Specifically i have one page where i store variables and pointers inside plugin API class with login screen and after login i need to redirect to another page and be able to access previously filled variables and pointers.
Simple answer? You can't. Plugins are specific to a single page. Any given plugin instance will be destroyed with the object tag that contains it is destroyed -- period. There are no exceptions to this rule.
That said, there are a few options you could try for what you're doing:
1) Rewrite your website to be AJAX and javascript driven so that all pages are actually the same page with different hashtags, etc. See http://backbonejs.org/ for one framework that helps with this. From the plugin perspective this is definitely the easiest solution, but it may require rewriting your entire website, which could be problematic.
2) Maintain state using your web application and pass the data back into the plugin on each page. You could do this through param tags or function calls once the plugin instantiates
3) Create some sort of "session" with your plugin with data stored in the global memory space; you could then resume the "session" on another page. For example:
if (!plugin.restoreSession("userid")) {
plugin.createSession("userid");
}
In this example createSession and restoreSession would be used to initialize or resume a given session. The challenge with this is that you have no idea how many tabs or pages are open using your plugin, so you could easily have collisions between the pages all accessing the same global data. In addition someone could create another web page that uses your plugin and restores a session and changes or accesses data, so it's a security risk. You could mitigate that by storing a domain name with the sessions and only allowing access to the session from the same domain, but... well, now you've basically just recreated cookies.
In addition, the browser does not actually guarantee how long your plugin module will be loaded; it could unload it on you at any moment that there are no active instances (between page requests). In practice it's much more likely that the plugin module would not be unloaded until the browser closes, which means any data you store in global memory in your plugin will not be freed and will continue taking up memory until you close the browser.
4) Create a browser extension that uses your plugin and works across multiple page requests. I have no idea how to do this, but things I have heard from others lead me to believe that it is possible. Keep in mind that you'd have to make one for each supported browser and it's probably not possible on IE; possibly only on Firefox/Chrome.
Since you're new to StackOverflow let me welcome you to the site and remind you whenever you post a question (not just this one!) to upvote helpful answers and try to always mark one as correct.