Create PHP session variable inside Kinetic.js/Javascript -
i trying create php session variable inside of kinetic.js/javascript.
stage.on('mousedown', function(evt) { var shape = evt.targetnode; if (shape) { if (shape.getfill() == 'green') { //$_session['room_name'] = shape.getattr('key'); window.location.href = 'create.php'; } } });
when shape clicked, want session variable store 'key' attribute, string, go 'create.php'.
how can this?
edit: cerbrus, tried suggestion:
stage.on('mousedown', function(evt) { var shape = evt.targetnode; if (shape) { if (shape.getfill() == 'green') { var img = new image(); img.src = "script.php?roomname=" + encodeuricomponent('hello'); window.location.href = 'create.php'; } } });
the user sent 'create.php', when tried print in 'create.php':
<?php echo $_get['roomname']; ?>
nothing echoed
you have set roomname parameter in url can read php script.
window.location.href = 'create.php?roomname='+ encodeuricomponent('hello');
you can same send id.
window.location.href = 'create.php?roomname='+shape.getattr('key');
Comments
Post a Comment