Solved

increment cookie value by one each time page is run

Posted on 2013-02-04
2
813 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 500 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

WordPress Tutorial 4: Recommended Plugins

Now that you have WordPress installed, understand the interface, and know how to install new parts, let’s take a look at our recommended plugins.

Question has a verified solution.

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

These days socially coordinated efforts have turned into a critical requirement for enterprises.
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

623 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