Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

increment cookie value by one each time page is run

Posted on 2013-02-04
2
Medium Priority
?
834 Views
Last Modified: 2013-02-04
<?php

      setcookie('increment_by_1_this_number','1',time()+300000);
            echo '<pre>';
      print_r($_COOKIE);
      echo '</pre>';

Open in new window



I want to increment by 1 the cookie value if cookie is set
0
Comment
Question by:rgb192
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 27

Accepted Solution

by:
Lukasz Chmielewski earned 2000 total points
ID: 38852205
<?php

    if (!isset($_COOKIE['increment_by_1_this_number'])) $_COOKIE['increment_by_1_this_number'] = 0;
    $visits = $_COOKIE['increment_by_1_this_number'] + 1;
    setcookie('increment_by_1_this_number',$visits,time()+300000);

    echo '<pre>';
    print_r($_COOKIE);
    echo '</pre>';

Open in new window

0
 

Author Closing Comment

by:rgb192
ID: 38852502
thanks
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this. Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it i…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question