Can I Get A Refund?

Sessions in PHP seemed to have changed since the last time I used them, so I’m looking for a simple way of using sessions but at the same time for it to be relatively secure and a good common practice.

2 ANSWERS

February 16, 2017 at 10:16 am admin

You can store PHP sessions in database, as described in this book. I have used this method and I find it secure and easy to implement, so I would reccomend it.

February 16, 2017 at 10:16 am admin

Session management changed some time back (I think it was around 4.4). The old mechanism still works, but is deprecated. It’s rather confusing, so I recommend staying clear of it. Today, you use sessions by accessing the global variable $_SESSION (It’s an array). You can put object instances in there, but you need to load the class definitions for those objects before starting the session on the next page. Using autoload can help you out here.

You must start a session before you can use $_SESSION. Since starting the session sends headers, you can’t have any output before. This can be solved in one of two ways: Either you always begin the session at the start of your script. Or you buffer all output, and send it out at the end of the script.

One good idea is to regenerate the session on each request. this makes hijack much less likely.
That’s (slightly) bad advice, since it can make the site inaccessible. You should regenerate the session-id whenever a users privileges changes though. In general that means, whenever they log in. This is to prevent session-fixation (A form of session-hijacking). See this recent thread @ Sitepoint for more on the subject.

Using cookiebased sessions only is OK, but if you regenerate session id’s on login, it doesn’t add any additional security, and it lowers accessibility a bit.

Viewing 2 replies - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

Some of our services that will useful on regular basis:

Book Tours & Activities

Access to a thousands of activaties in Costa Rica. Everything from Adventure, Arts and Recreational Activities.

Tranportation Bookings

Booking your trasfers has never been easier. Look up available destications, times and get instant confirmation with just a few clicks.

Investments

Great resource for those who are looking for business and investment opportunities for residential and commercial real estate.

Online Shopping

Shop Online for Costa Rica made products and services. Find Unique and one of kind items.

Services Bookings

Make reservation at your favorite locations and events.

Hotel Bookings

Get access to all the hotels in Costa Rica. Check availability and book

Vacation Rentals

Search all the available vacation home rentals in Costa Rica.

Book A Table

We make it easy for you to make a reservation with your favorite place.

Order Food

Place your oder online and have your food deliver to your location. Restritions apply.

Flight Booking

Look for best deals and book your flights with us.

Rent A Car

Quick, easy online car reservations for Costa Rica.

Bank / ATM

Locate Bank and ATM information

Doctors Appointment

Schedule your appointmens directly with our participating providers.

Spa & Salon

Book your spa and salon treatments directly with our participating providers.

Offers | Promotions | Hot Deals

Explore best offers, promotions and hot deals with AskZipy.

On Demand Services

Book your on damand services directly with our participating providers.

Jobs

Looking for work, search our site to find business who are looking for talent to join their teams.

Photo Album

View photos form all the Ask Zipy adventures and activaties.

Emergency Services

Locate Emergency services locations and contact information.

FAQ

Search our list of faqs to the most common questions people have when visiting and working in Costa Rica.

Order Groceries

Shopping for groceries has never been easier. order your groceries and have them delivered to your location.