Codeigniter session using database not working in Google App Engine Flexible Environment

조회수 990회
읽지 않은 첫 메시지로 건너뛰기

Dhandapani Sattanathan

읽지 않음,
2017. 5. 3. 오전 5:51:2517. 5. 3.
받는사람 Google App Engine

I m migration my CRM application developed in CodeIgniter Framework from GAE SE to Google App Engine flexible environment.


UserService not available in GAE FE.So I used Integrating Google Sign-In into your web app.


I need session so I used the below.I am using CI_VERSION', '3.0.0


application/config/config.php

$config['sess_driver'] = 'database';
$config
['sess_cookie_name'] = 'ci_session';
$config
['sess_expiration'] = 7200;
$config
['sess_save_path'] = 'ci_sessions';
$config
['sess_match_ip'] = TRUE;
$config
['sess_time_to_update'] = 300;
$config
['sess_regenerate_destroy'] = FALSE;

Using the below query I created the ci_sessions table in second generation cloud SQL.


CREATE TABLE IF NOT EXISTS `ci_sessions` (
`id` varchar(40) NOT NULL,
`ip_address` varchar(45) NOT NULL,
`timestamp` int(10) unsigned DEFAULT 0 NOT NULL,
`data` blob NOT NULL,
PRIMARY KEY
(id),
KEY
`ci_sessions_timestamp` (`timestamp`)
);


I can get session userstamp in ctrl_Index.php


application/controllers/Ctrl_Index.php

<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Ctrl_Index extends CI_Controller {

public function index()
{
$userstamp
=base64_decode($_GET['UserStamp']);
$this
->session->set_userdata('UserStamp', $userstamp);
echo $this
->session->userdata('UserStamp'); // here session id came.
$this
->load->view('Vw_Menu'); // Redirect to vw_menu page.

}
}

?>


application/views/Vw_Menu.php

<?php
?>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$
(document).ready(function(){
var CONFIG_ENTRY_controller_url="<?php echo base_url(); ?>" + '/index.php/Ctrl_Menu/' ;
$
.ajax({
type
: "POST",
url
':CONFIG_ENTRY_controller_url+"getSessionUserstamp",
success
: function(data){
$
(".preloader").hide();
var userstamp=(data);
alert
(userstamp)

});

});
</script>
<title>CI SESSION IN GAE FE</title>
<meta charset="utf-8">
</head>
<body id="bodyMenuMsg">
<form class="form-horizantal">

</form>
</body></html>


From Ctrl_index.php redirect to vw_menu.php session got empty.Also ci_sessions tables ip_address saved as empty.


My sample script can see here [1], Download Codeigniter here [2] replace my sample script.


Will ci-sessions using database work in GAE FE?.Is there any other alternative to using ci-session in GAE FE?


Maybe I missed configuring in GAE FE to work ci_session?


Please help me.


Thanks in advance


SN


Justin Beckwith

읽지 않음,
2017. 5. 3. 오전 11:00:2517. 5. 3.
받는사람 google-a...@googlegroups.com, Brent Shaffer, Takashi Matsuo, Jeffrey Ching
+ a few folks

--
You received this message because you are subscribed to the Google Groups "Google App Engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/5220d656-7264-4d89-9841-075f6e1576fc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Justin Beckwith | Google Cloud Platform | @justinbeckwith | http://jbeckwith.com

Takashi Matsuo

읽지 않음,
2017. 5. 3. 오후 1:32:5817. 5. 3.
받는사람 Justin Beckwith, google-a...@googlegroups.com, Brent Shaffer, Jeffrey Ching

Hi Dhandapani,

Are you able to connect to the database in other part of your app?
Are there any suspicious logs?

+ a few folks

To unsubscribe from this group and stop receiving emails from it, send an email to google-appengi...@googlegroups.com.
To post to this group, send email to google-a...@googlegroups.com.
--

Justin Beckwith | Google Cloud Platform | @justinbeckwith | http://jbeckwith.com
--
-- Takashi

Takashi Matsuo

읽지 않음,
2017. 5. 3. 오후 4:22:4617. 5. 3.
받는사람 Justin Beckwith, google-a...@googlegroups.com, Brent Shaffer, Jeffrey Ching

Hi Dhandapani,

Just a quick note, I downloaded CodeIgniter 3.1.4 and the session with the database backed by CloudSQL v2 works.

Potential pitfalls are:
  • You have to enable Cloud SQL API
  • You have to add beta_settings in your app.yaml
    ```
    beta_settings:
      cloud_sql_instances: "CONNECTION_NAME"
    ```
  • If you're using mysqli, put the default socket in php.ini
    ```
    mysqli.default_socket= '/cloudsql/CONNECTION_NAME'
    ```
Hope it helps!
--
-- Takashi

Dhandapani Sattanathan

읽지 않음,
2017. 5. 4. 오전 12:32:0817. 5. 4.
받는사람 Google App Engine, beck...@google.com, bette...@google.com, chi...@google.com
Hi Takashi,

Yes without the session, I can connect to the database. All forms working.There are no suspicious logs.

Dhandapani Sattanathan

읽지 않음,
2017. 5. 4. 오전 1:33:5117. 5. 4.
받는사람 Google App Engine, beck...@google.com, bette...@google.com, chi...@google.com
Hi Takashi,

I enabled Cloud SQL API & added beta_settings in my app.yaml.

I m using mysqli. I didn't used mysqli.default_socket= '/cloudsql/CONNECTION_NAME in php.ini.

Also, I used CodeIgniter 3.0.0. I 'll try with CodeIgniter 3.1.4 with session & mysqli.default_socket in php.ini and Let you know the status.

Thanks for immediate reply 

-SN

Dhandapani Sattanathan

읽지 않음,
2017. 5. 5. 오전 11:50:2717. 5. 5.
받는사람 Google App Engine, beck...@google.com, bette...@google.com, chi...@google.com
Thanks, Takashi,

I tried with CI 3.1.4 with sessions. I changed base URL for GAE. Previous versions can work without changing BASE URL.

I added  mysqli.default_socket= '/cloudsql/CONNECTION_NAME', As per reply.

In the view I got issues, I fixed, Now working fine CI SESSIONS IN FE.

thanks for all Support. If I get any other issues Will contact you
전체답장
작성자에게 답글
전달
새 메시지 0개