Welcome Guest, Not a member yet? Register   Sign In
can't access $_SESSION in another file. Hand made captch
#1

(This post was last modified: 07-28-2017, 01:28 AM by glorsh66.)

In a nutshell i making my own - very simple captcha, that does not use temp files. Just simple output image directly.
In the view i just use this 
Code:
<img src="../../myscripts/captcha.php" class="rounded-circle"/>

And  captcha itsef - 
Code:
<?php
session_start();
$code=$_SESSION['expire'];
#######################################################################
#                PHP Simple Captcha Script
#    Script Url: http://toolspot.org/php-simple-captcha.php
#    Author: Sunny Verma
#    Website: http://toolspot.org
#    License: GPL 2.0, @see http://www.gnu.org/licenses/gpl-2.0.html
########################################################################
$im = imagecreatefrompng('../img/dogecoin-300.png');
$bg = imagecolorallocate($im, 22, 86, 165);
$fg = imagecolorallocate($im, 255, 255, 255);


$initial_rast = 80;
for($i = 0; $i < strlen($code); $i++){
    $rand_angle = rand(-30,30);
    $initial_rast=$initial_rast+$i+20;
    imagefttext($im,20,$rand_angle,$initial_rast,100,$fg,'../fonts/DogeSans-Regular.otf',$code[$i]);
}

header("Cache-Control: no-cache, must-revalidate");
header('Content-type: image/png');
imagepng($im);
imagedestroy($im);
?>

Every thing is super fine, except it doesn't work☻
I mean it works fine only outside CI.

The problem is - i can't accesses $_SESSION['expire'] - that i made in controller.
(but it work perfectly fine if i use just another php file that lying around and is not a part of CodeIgniter).
It seems that CI - makes another instance of session, if it is placed on another subdomain.
Any thought? How can i pass parameters to this captcha.php file?
Reply
#2

I just solved my problem with captcha. I made additional controller (captcha controller) and in view make a link to the aforementioned controller <img src="http://testsite/Testcintroller" class="rounded-circle"/>. Because it is a controller it can access any data, including sessions.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB