I am into development of a cakePHP based web application.
Here are my core.php settings for session handling
Configure::write('Session.save', 'database');
/**
* The name of the table used to store CakePHP database sessions.
*
* 'Session.save' must be set to 'database' in order to utilize this constant.
*
* The table name set here should *not* include any table prefix defined elsewhere.
*/
Configure::write('Session.table', 'cake_sessions');
/**
* The DATABASE_CONFIG::$var to use for database session handling.
*
* 'Session.save' must be set to 'database' in order to utilize this constant.
*/
//Configure::write('Session.database', 'default');
Configure::write('Session.start', true);
/**
* The name of CakePHP's session cookie.
*/
Configure::write('Session.cookie', 'CAKEPHP');
/**
* Session time out time (in seconds).
* Actual value depends on 'Security.level' setting.
*/
Configure::write('Session.timeout', '300');
/**
* If set to false, sessions are not automatically started.
*/
Configure::write('Session.start', true);
/**
* When set to false, HTTP_USER_AGENT will not be checked
* in the session
*/
Configure::write('Session.checkAgent', true);
/**
* The level of CakePHP security. The session timeout time defined
* in 'Session.timeout' is multiplied according to the settings here.
* Valid values:
*
* 'high' Session timeout in 'Session.timeout' x 10
* 'medium' Session timeout in 'Session.timeout' x 100
* 'low' Session timeout in 'Session.timeout' x 300
*
* CakePHP session IDs are also regenerated between requests if
* 'Security.level' is set to 'high'.
CakePHP session id is always blank. although other session read/write activities are working perfectly fine.
Below is the session object.
SessionComponent Object
(
[__active] => 1
[__started] =>
[__bare] => 0
[valid] =>
[error] => Array
(
[2] => Auth.redirect doesn't exist
)
[_userAgent] => 2abebfb51fc971ec64569f7cd415fe0b
[path] => /
[lastError] => 2
[security] => high
[time] => 1278950154
[sessionTime] => 1278953154
[watchKeys] => Array
(
)
[id] =>
[_log] =>
[host] =>localhost
[enabled] => 1
[cookieLifeTime] => 0
)
All the other session variable are stored and retrieved properly, the problem is I am not getting session id at any stage.
Can you please help me what can be problem.
Thanks,
Sourabh
use session_id()
I hope it will work for you.
I had such experience and it's not good at all. Check if any of the resources are missing. I.e. some images, css or js files could be missing and then Cake loads the missing controller/action page which could reset the session.
refer to cakephp session id Empty
try to start the session with
$this->Session->start();
Related
learning to use xampp for localhosting wordpress, at the end of tutorial where you enter info database, username, pass etc
cant get a connection, i assume it has to do with username,database and password credentials.
ive tried changing everything in wp-config-sample, and even checked out setup-config which didnt seem as other tutorials described, alot more code.
Im trying to understand that i am entering everything correctly, i believe at one point i put my phpmyadmin server on port 3307. down below is a picture of the form page in browser and code from config-sample, setup-config is pretty big, i will add if it is suggested
<?php
/**
* The base configuration for WordPress
*
* The wp-config.php creation script uses this file during the installation.
* You don't have to use the web site, you can copy this file to "wp-config.php"
* and fill in the values.
*
* This file contains the following configurations:
*
* * Database settings
* * Secret keys
* * Database table prefix
* * ABSPATH
*
* #link https://wordpress.org/support/article/editing-wp-config-php/
*
* #package WordPress
*/
// ** Database settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'wordtests' );
/** Database username */
define( 'DB_USER', 'root' );
/** Database password */
define( 'DB_PASSWORD', '' );
/** Database hostname */
define( 'DB_HOST', 'localhost' );
/** Database charset to use in creating database tables. */
define( 'DB_CHARSET', 'utf8' );
/** The database collate type. Don't change this if in doubt. */
define( 'DB_COLLATE', '' );
/**##+
* Authentication unique keys and salts.
*
* Change these to different unique phrases! You can generate these using
* the {#link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service}.
*
* You can change these at any point in time to invalidate all existing cookies.
* This will force all users to have to log in again.
*
* #since 2.6.0
*/
define( 'AUTH_KEY', 'put your unique phrase here' );
define( 'SECURE_AUTH_KEY', 'put your unique phrase here' );
define( 'LOGGED_IN_KEY', 'put your unique phrase here' );
define( 'NONCE_KEY', 'put your unique phrase here' );
define( 'AUTH_SALT', 'put your unique phrase here' );
define( 'SECURE_AUTH_SALT', 'put your unique phrase here' );
define( 'LOGGED_IN_SALT', 'put your unique phrase here' );
define( 'NONCE_SALT', 'put your unique phrase here' );
/**##-*/
/**
* WordPress database table prefix.
*
* You can have multiple installations in one database if you give each
* a unique prefix. Only numbers, letters, and underscores please!
*/
$table_prefix = 'wp_';
/**
* For developers: WordPress debugging mode.
*
* Change this to true to enable the display of notices during development.
* It is strongly recommended that plugin and theme developers use WP_DEBUG
* in their development environments.
*
* For information on other constants that can be used for debugging,
* visit the documentation.
*
* #link https://wordpress.org/support/article/debugging-in-wordpress/
*/
define( 'WP_DEBUG', false );
/* Add any custom values between this line and the "stop editing" line. */
/* That's all, stop editing! Happy publishing. */
/** Absolute path to the WordPress directory. */
if ( ! defined( 'ABSPATH' ) ) {
define( 'ABSPATH', __DIR__ . '/' );
}
/** Sets up WordPress vars and included files. */
require_once ABSPATH . 'wp-settings.php';
If you were to browse to my website you would see I have database connection issues. I get CakePHP's error message telling me the file is missing. I've checked several times and everything I'm using cakePHP3. I must have screwed up sonewhere, but I don't want to start all over again If you were to look at my code:
<?php
/**
* This is core configuration file.
*
* Use it to configure core behaviour of CakePHP.
*
* PHP 5
*
* CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
* Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
*
* Licensed under The MIT License
* For full copyright and license information, please see the LICENSE.txt
* Redistributions of files must retain the above copyright notice.
*
* #copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* #link http://cakephp.org CakePHP(tm) Project
* #package app.Config
* #since CakePHP(tm) v 0.2.9
* #license http://www.opensource.org/licenses/mit-license.php MIT License
*
* Database configuration class.
* You can specify multiple configurations for production, development and testing.
*
* datasource => The name of a supported datasource; valid options are as follows:
* Database/Mysql - MySQL 4 & 5,
* Database/Sqlite - SQLite (PHP5 only),
* Database/Postgres - PostgreSQL 7 and higher,
* Database/Sqlserver - Microsoft SQL Server 2005 and higher
*
* You can add custom database datasources (or override existing datasources) by adding the
* appropriate file to app/Model/Datasource/Database. Datasources should be named 'MyDatasource.php',
*
*
* persistent => true / false
* Determines whether or not the database should use a persistent connection
*
* host =>
* the host you connect to the database. To add a socket or port number, use 'port' => #
*
* prefix =>
* Uses the given prefix for all the tables in this database. This setting can be overridden
* on a per-table basis with the Model::$tablePrefix property.
*
* schema =>
* For Postgres/Sqlserver specifies which schema you would like to use the tables in. Postgres defaults to 'public'. For Sqlserver, it defaults to empty and use
* the connected user's default schema (typically 'dbo').
*
* encoding =>
* For MySQL, Postgres specifies the character encoding to use when connecting to the
* database. Uses database default not specified.
*
* unix_socket =>
* For MySQL to connect via socket specify the `unix_socket` parameter instead of `host` and `port`
*
* settings =>
* Array of key/value pairs, on connection it executes SET statements for each pair
* For MySQL : http://dev.mysql.com/doc/refman/5.6/en/set-statement.html
* For Postgres : http://www.postgresql.org/docs/9.2/static/sql-set.html
* For Sql Server : http://msdn.microsoft.com/en-us/library/ms190356.aspx
*/
class DATABASE_CONFIG {
public $default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'username',
'password' => 'password', // db credentials removed
'database' => 'database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
public $test = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'user',
'password' => 'password',
'database' => 'test_database_name',
'prefix' => '',
//'encoding' => 'utf8',
);
}
I don't know why Cake is not recognizing my file. I have the file placed properly in the directory it should be in. I remember trying to make the app work on shared hosting and that is how my Cake 2 thing might have been introduced. I'm stuck, guys.
I tried with many things and it always said the same i need return the user or the list of all users
i dont know what happen,
resul returns Resource id and
if i print mysql_fetch_array it returns Array and print r doesnt return all users in my database
<?php
,
$consulta = "SELECT user FROM usuarios";
$resul = mysql_query($consulta,$conexion);
echo $resul;
print_r(mysql_fetch_array($resul));
?>
with phpmyadmin return all users.. that query works fine when i put that with phpmyadmin
i have in that moment in the database one table called usuarios with 3 columns called user(admin,pablo) pass(admin,pablo) and obviously id
but the ouput is this
Resource id #2Array ( [0] => admin [user] => admin )
I want to implement oracle streams in different schema name..for example
schema1.jobs to schema2.jobs
because most of people give example in same schema..like scott.emp to scott.emp :(
anybody have any advice and thread ?
thank you so much :)
you must configure the apply process. To do this you should add rules to the rule set. With this configuration, the apply process dequeues the LCR (Logical Change Record) events and applies all changes to the destination schema. In order to do this, execute the following in the destination DB as strmadmin user:
SQL> begin
dbms_streams_adm.add_schema_rules (
schema_name => 'XXX',
streams_type => 'apply',
streams_name => 'apply_strm',
queue_name => 'capture_Downstream',
include_dml => true,
include_ddl => true,
source_database => 'SOURCE_GLOBAL_NAME');
end;
/
You should adjust the parameters based on your case. See the https://docs.oracle.com/cd/B10501_01/appdev.920/a96612/d_strm_2.htm it is for 9.2
In CakePHP I have two models: Clients & Tickets. A client can have many tickets and a ticket can only have 1 client.
When adding a new ticket I want to automatically create a new client by only entering a name. So the form would be:
Name = "Name client" >> Name should be save in Client table en new client_ID in Ticket table
Info = Ticket information >> Save in Ticket table.
"Save"
I'm not sure how this works. I have associations in the model and tried to saveAll but there is no data stored in the Client table. And how do I get the ID in the Ticket table?
Hope someone can point me in the right direction. I've searched for other answers but cant seem to find a solution. Is saveAll the right way to do this?
You should set a php condition before insert values into the table, the sql request 4 exemple return the numbers of repetition of the same ticket_id so if the returned value is greater than 1 the request can't execute else the request insert the values
The function to count number of rows : mysql_num_rows('request');
You can use the callback methods.
If you have defined your relation in the Ticket model with belongsTo Client, it will be accessible from that model.
public $belongsTo = array(
'Client' => array(
'className' => 'Client',
'foreignKey' => 'client_id',
),
);
So, if you want to make a new client before saving the ticket, you can do:
public function beforeSave ($options = array()) {
$this->data['Client']['name'] = $someVar;
$this->Client->save($this->data);
$this->data[$this->alias]['client_id'] = $this->Client->getInsertID();
return true;
}