Creating A Custom Handler Session In CakePHP 2.x

Sessions manage and customization is very easy in CakePHP. Setting and configuration come out of the box so basically you don’t need to configure at all. But still at some point we need customization like, if we need some changes in php.ini or want to store session in a different place.

You can manage session, write custom handler, add option to save on different places, override php.ini settings.

Write Your Own Custom Handler For Sessions in Cake:

To Save Session With Setting in php.ini:

Configure::write('Session', array(
'defaults' => 'php'
));

This is the default setting that comes out of the box by CakePHP.

To Save Session Inside Cake tmp Folder:

Configure::write('Session', array(
'defaults' => 'cake'
));

This is required in a host where it does not allow you to write outside your home directory.

To Save Session in Database:

Configure::write('Session', array(
'defaults' => 'database'
));

This uses a built-in database defaults. It stores session in ‘cake_sessions’ table.
So you need to create a table for this:

CREATE TABLE `cake_sessions` (
`id` varchar(255) NOT NULL DEFAULT '',
`data` text,
`expires` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
);

But you can specify you own session handler to store session using a different model:

Configure::write('Session', array(
'defaults' => 'database',
'handler' => array(
'model' => 'MyCakeSession'
)
));

Create ‘MyCakeSession’ model at app/Model/MyCakeSession.php  And create ‘my_cake_sessions’ table:

CREATE TABLE `my_cake_sessions` (
`id` varchar(255) NOT NULL DEFAULT '',
`data` text,
`expires` int(11) DEFAULT NULL,
PRIMARY KEY (`id`)
);

This will save session ‘my_cake_sessions’ using MyCakeSession model.

To Save Session in Cake Cache:

Configure::write('Session', array(
'defaults' => 'database'
));

Making Session Persist Across All Sub-Domains:

  • Add below in bootstrap:
    ini_set(‘session.cookie_domain’, env(‘HTTP_BASE’));
  • This changes the default, that only the domain generating a session can access, to all sub-domains.
  • You don’t need to make core Security.level to low or medium.
  • You can also use php, cake, database or cache in core Session default to persist session in all sub-domains.

Troubleshoot:

  • When you test with the session management you might get error: “cakephp 404 The request has been black-holed”.
  • Try clear tmp/cache/, tmp/cache/models, tmp/cache/persistent, tmp/sessions.
  • Try clear browser cookie and cache.
  • Check core Session configurations.

Always try to clear browser cookie, cache before doing changes in core Session or php.ini configuration.

Other Session configuration that can be done are cookie name, timeout, cookieTimeout, checkAgent, autoRegenerate, and other ini values like cookie_secure, cookie_path, cookie_httponly.

See Also : How to migrate CakePHP 1.x to 2.x

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.

Advantages and Disadvantages of Hiring Remote Team

In recent time, it has been seen that more and more business owners are open to remote teams; whereas, some entrepreneur are still in dilemma whether to hire remote team because they don’t have any clue how to adapt to remote group. So today, here I will pinpoint some points that will help entrepreneur to make decision easily.

Advantages to hiring remote or virtual team:

1. Get better talent at much low cost:

You can hire people who are either in your city or eager to move and you know great talent doesn’t live next door. Sometime, even if you get that talent near to, but may be out of your budget. However remote team is providing a feasible option to hire best talent from anywhere in the world and that will be within your budget.

2. Low office cost:
Office Rent, electricity, computer, and other equipment added significant ongoing cost. So again by hiring remote team you can easily cut out this unnecessary costs.

3. Increased productivity:
If you think employees working in an office are more productive than remote team, then the report released on Staples Advantage is definitely an eye opening for you.

  • 48% of remote workers say they are less stressed
  • 53% of employers with remote workers report more productive employees
  • 75% of business decision makers notice happier employees

Generally remote team get much longer and uninterrupted period of time to get more productive work.

4. Saving time from unproductive meetings:
Generally unnecessary meeting and distraction from co-worker waste productive time a lots. These are some common problem in office which can be easily rid out by hiring a remote team.

5. Provide flexible time option:
Remote team helps you to work 24*7 basis which again speedup your productivity.

6. If your job is temporary in nature:
If you are a business owner and want a team who can work for you for fixed time period on contract basis then again remote team is nice option for you. You can easily scale up or reduce or team as per your requirements.

7. Professional Approach :
It has been seen that remote teams follow more professional approach than in-house team to their job rather because they are looking for long run business association with the entrepreneur.

Problem of working with distributed or remote team:

1. Lack of communication between remote team and you :
It is very much obvious that, if you work with in-house team, then you can easily go to someone desk at any time and do the casual discussion; where in case of virtual team you have to schedule a meeting to discuss about your project. Definitely this is a major issue but in the flip side it will spare bunches of time which will devoured by ineffective talk and diversion from companions. Likewise that, the virtual team made extra, deliberate  effort to ensure that they communicate with smoothly.

Some of the tools that help you to communicate with you virtual team: Skype , OrangeScrum(Project Management tool), Basecamp, Google Dropbox and Hangouts etc. Also see our previous post: Top 10 simple tools you should know for working with remote team

2. Hard to work with remote time :
More often that remote teams belongs to different timezone, so it gets hard to work at the same time with remote team that you can generally do with your office employees, and it becomes one of major issue people find remote team is not viable option for them. However, it learns you to work asynchronously.

Really the hindrances of working a virtual group are blessings in disguise.

If you opt for remote developers who work on your project dedicatedly, then Andolasoft is an ideal and savvy option for you.

Like this blog? I’d love to hear about your thoughts on this. Thanks for sharing your comments.

Top 10 simple tools you should know for working with remote team

remote_development_work-123There has been a sharp increase in Remote Development team in different parts of world, who provide product development, support and maintenance services.

Looking into current demand for skilled pool of Dedicated Developers, it is efficient to hire skilled developers and designers who are located at remote locations and use the right tools to chat, video conference, share screen and keep all the tasks in single place to develop your product efficiently and cost-effectively.

Here are the 10 must have tools to set up a virtual office and work with your remote team:

1. Skype:

Skype_logo

 

 

 

Skype is a voice and text based Instant messaging system that works on the VOIP technology. If you have a microphone and speaker, you can make phone free calls from your computer to other people on Skype and make cheaper calls to landlines and cell phones. Other features include instant messaging, file transfer, video conferencing and screen sharing. Skype also has an Internet connection box that lets you convert your regular telephone to use the internet for telephone service.

 

2. Google+ Hangouts:

Google_Hangouts

 

 

 

It is a free video chat service that offers both ‘one-on-one’ and group chats with up to ten people at a time. It focuses more on “face-to-face-to-face” group interaction as opposed to one-on-one video chats, and makes use of sophisticated technology to seamlessly switch the focus to the person currently chatting. It provides a ‘Hangouts on Air’ to broadcast live video conversation which are accessible to anyone with web browser.

3. join.me

join.me_image

 

 

 

 

join.me is a free one click screen sharing and conferencing tool. Just download the app, run and share the URL and you’ve got instant screen sharing along with text chat, voice conferencing as well as mouse sharing (if you allow it). You can also voice chat while watching the demonstration on the shared screen and even share files.

4. Cisco WebEx:

CiscoWebex_image

 

 

 

It is an on demand collaboration, web conferencing, online meeting and video conferencing app.  It is a full-fledged service that offers Screen sharing, audio and video recording, meeting scheduling and future event scheduling tools for both presenters and participants.

5. Orangescrum:

OrangeScrum_new_logo

 

 

 

 

There are numerous project collaboration tools available. However, we used Orangescrum which is developed by our development team. It is a project collaboration tool for project handling and effective communication between the developers and customers. It facilitates file attachments of any size and format; assigning tasks to a group. Set e-mail alerts as well as prioritize and target them to the concerned team members. It has got everything that a project collaboration tool demands.

 

6. Google Docs:

Google_logo

 

 

 

 

Google Docs is a free web based application in which documents and spreadsheets can be created, edited at the real time. Files can be accessed remotely form any PC with an internet connection and a Web browser. Users can import and edit docs and spreadsheets in various fonts, formats, formulas, lists, tables and images. Multiple users can work together in real time from remote locations.

 

7. DropBox:

Dropbox_image

 

 

 

 

 

DropBox is a personal cloud storage service which is used for file sharing and collaboration. It automatically updates the file changes across multiple devices which can be accessed from the DropBox repository. It can also be used with Android, iOS and windows mobile devices. Along with file sharing it also offers file versioning which are saved automatically.

 

8. Google Calendar:

Google_logo

 

 

 

Google Calendar app facilitates users to create private and public calendars. It store the calendars within its own servers hence, can be accessed from anywhere through a Web browser. This is probably the best app for scheduling and managing your events and meetings.

 

9. Sqwiggle:

sqwiggle1

 

 

 

 

Sqwiggle is browser-based group video chat service. They also have a stand-alone client for OS-X. According to TechCrunch- “It’s got the office-like immediacy that Skype lacks, but without the noise of a Google Hangout”

 

10. HipChat:

HipChat

 

 

HipChat is a private chat and instant messaging service that allows users to create and join chat rooms and send one-on-one messages with other users. Other primary features include searchable chat history, sharing images, uploading files and also SMS messaging for one-to-one conversation.

Kick off Your Small Business with Magento Go

With internet prevailing its effect on every corner, businesses got the chance to spread across the world.

Once a small cotton factory is now the biggest ready-made clothing supplier of the world and this is not a single instance as there are millions like this.

Keeping that legacy alive, Magento development platform launched the online eCommerce building platform Magento Go. It lets you develop an online store for your small business with very much less investment.

And the best thing is you don’t need to be a techno-buff for this due to its simplest operations and easy learning interface.

Magento introduced a SaaS (software-as-a-service) version of its e-commerce platform named Magento Go. It allows small businesses or merchants to build easy-to-use shopping portals for customers around the world.

If you’re thinking of setting up an online store for your various product ranges, then it can help you build your store with your designs.

Magento Go include some basic features like Order Management, Customer Analytics and some cool features like Coupons and Gift Cards, which were not available in the Magento Community edition.

The designs, impressive templates, product flexibility, and search engine friendliness are some of the major features in Magento Go.

Magneto Development team recently updated additional features to Magento Go for merchants of the United Kingdom like Royal Mail Shipping, UK Cookie law compliance, improved PayPal payments, VATs and many more.

A trial out period of 30 days is available which can be then subscribed with fewer cost plans to run your e-commerce business. Customer engagement majors like assisted shopping, product comparisons, and wish lists are also taken to make the interactions more useful.

It Connect which is a market for a place for other Magento Go plug-ins is available for merchants who want to add additional features to their stores.

It is really going to kick off your small business if you know optimal utilization of the resources available to reach the maximum number of people.

At Andolasoft we’ve got expert developers on Magento development who have broad experience over handling individual projects on Magento. We have been developing the best quality, highly scalable websites for small to large scale enterprises.

Whether you’re a start-up eCommerce business or a large retailer switching to eCommerce, we can help you by building search friendly and secure websites as per your requirements.

 

Integration of Google reCaptcha with Rails application

ReCaptcha is a powerful captcha service to be use with a form to stop spam. This blog demonstrates the use of reCaptcha in rails application. Here I have used the ruby version 1.9.3 and Rails version 3.2.8.

Environment

  • Ruby version – 1.9.3
  • Rails – 3.2.8

Step#1

Create an account with Recaptcha “http://www.google.com/recaptcha” and register your site name with your google account to retrieve the public and private key that will be used later on the application

Step#2 

Installation of Recaptcha

  • Gem
  • Open your Gemfile and add this code
gem 'recaptcha', :require => 'recaptcha/rails'
  • Plugin
  • rails plugin install git://github.com/ambethia/recaptcha.git

Step#3

Create a file named recaptcha.rb in RAILS_ROOT/config/initializer and fill it with these codes

ENV['RECAPTCHA_PUBLIC_KEY'] = 'youractualpublickey' ENV['RECAPTCHA_PRIVATE_KEY'] = 'youractualprivatekey'

Step#4

Usages Open your views file and add this code

<%= recaptcha_tags %>

Step#5

Validation In controller, you can check the captcha validation by the following

if @model.save && verify_recaptcha(:model => @developer, :message => "Oh! It's error with reCAPTCHA!") #captcha is valid else #captcha is invalid end

How to use Nested Attributes in Rails 3 Forms

For example, say we want to add multiple addresses(attributes) having many fields inside a create/edit employee form

Step# 1

  •         Create a model named Employee
  •         Create another model named Address
  •         Add the following relationship in Employee model
class Employee < ActiveRecord::Base
has_many :addresses, :dependent => :destroy
accepts_nested_attributes_for :addresses, :reject_if => lambda { |a| a[:city].blank? }
end
  •    Nested attribute form rejects if the city field of the address is blank

Step# 2

  •        In Employees controller add the following in the “new” action
def new
@employee = Employee.new
@employee.addresses << Address.new
end

Step# 3

  •         In the view file add the following inside the form attribute
<%= form_for @employee, :html => { :multipart => true, :id => 'new-employee' } do |f|
<%= f.label :name, 'Name' %>
<%= f.text_field :name %>
 
<% end %>