Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat | DONATE
UrlLoader and sessions — Gideros Forum

UrlLoader and sessions

ar2rsawseenar2rsawseen Maintainer
edited November 2012 in Code snippets
I was interested if Gideros UrlLoader could work with sessions, so I created a little test.
Here's a simple PHP script, that initialize session on first call and prints out session variables on second
<?php
session_start();
if(!isset($_SESSION["test"]))
{
	$_SESSION["test"] = "test";
	echo "Session init";
}
else
{
	print_r($_SESSION);
}
?>
So first attempt I tried to reuse same UrlLoader instance:
local loader = UrlLoader.new()
local function onComplete(e)
	print(e.data)
end
loader:addEventListener(Event.COMPLETE, onComplete)
loader:load("<a href="http://localhost/test.php&quot" rel="nofollow">http://localhost/test.php&quot</a><img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/wink.png" title=";)" alt=";)" height="20" />
Timer.delayedCall(2000, function()
	loader:load("<a href="http://localhost/test.php&quot" rel="nofollow">http://localhost/test.php&quot</a><img class="emoji" src="http://forum.giderosmobile.com/resources/emoji/wink.png" title=";)" alt=";)" height="20" />
end)
And result is yes, session was stored successfully, thus the output:
Uploading finished.
Session init
Array
(
    [test] => test
)
Nice! It means somewhere deep in there cookies are stored.

Then I tried to use different instances and result is the same. Meaning cookies stored are the same for all UrlLoader instances.

But if you exit the app and open it again, session will be initialized from the start.

In any other way feel free to use sessions in Gideros with UrlLoader ;)

Likes: moopf

+1 -1 (+1 / -0 )Share on Facebook

Comments

Sign In or Register to comment.