Archive for August, 2006

I can see my home from sky!!

August 24, 2006 4 comments

I have not been to my home since one year back. Really I am missing my home and my city also. Now I got the way, I can visit my city and my home through my PC. Looks exiting? yes for me also. Atleast I can watch my home from sky. This is what WikiMapia does. Words from Wikipedia
“WikiMapia is an online map resource that combines Google Maps with a wiki system, allowing users to add information (in the form of a note) to any location on the globe. Created by Alexandre Koriakine and Evgeniy Saveliev, the project was launched on May 24, 2006 and is aiming towards “describing the whole planet Earth“.
Do you really want to have an exiting tour to your home, come on WikiMapia

Categories: Myidea

Have some Cookies!!

August 21, 2006 Leave a comment

Q: What are cookies?

Ans: A Cookie is a small amount of data stored on the client’s browser in compliance with a request from a server or script. The information is constantly passed in HTTP headers between the browser and web server; the browser sends the current cookie as part of its request to the server and the server sends updates to the data back to the user as part of its response. Once a cookie is created, it will expire after a specified time period.

Q: What is the need of cookies?

Ans: HTTP is a stateless protocol. Therefore, every-page a user downloads from your server represents a separate connection.

1-Cookies allow you to do neat things, like automatically log a user into your site when he loads a page in his browser, or store temporary information about your user, such as what items he has in a shopping cart.

2- Allows a user to remain ‘logged on’ until he explicitly logs out or the browser window is closed.

3- After a cookie is set, only the originating host can read the data, ensuring that the user’s privacy is respected.

Q: How we can set a cookie?

Anw: You can set a cookie in a PHP script in two ways:

Using header() function:

header(“SET-COOKIE: newcookie=mycookie; expires=Sat, 26-Aug-06 14:40:28 GMT; path=/;”);

Using setcookie() function:

setcookie(name, value, expiration, path, domain, secure, httponly);



setcookie(“newcookie”, “mycookie”, time()+3600, “/”,””, 0);



<head><title>Setting a new cookie</title></head>


<?php if(isset($_COOKIE[‘newcookie’])) {

echo “<p> Hello again, your chosen cookie is “;

echo “{$_COOKIE[‘newcookie’]} </p>”;

} else {

echo “<p> Hello you. This may be your first visit</p>”;

} ?>



Q: How to access the already set cookie?

Ans: With the help of the superglobal variable $_COOKIE[‘cookie_name’]

Q: How to determine the expiration of the cookie?

Ans: The “expiration” variable in the setcookie() function decides the expiration of the cookie. Here are some amount of time which signify the determination of the expiration time/date of a cookie

One Minute: 60
Ten Minutes: 600
Half-an-Hour: 1800
One Hour: 3600
One Day: 86400
One Week: 604800
Two Weeks: 1209600
One Month (30 days): 2592000
One Year (365 days): 31536000

Q: How to delete a cookie?

Ans: There are two ways to reset/destroy a cookie:

Reset a cookie by specifying already expired time:-

setcookie(“newcookie”, “”, time()-60, “/”, “”, 0);
Reset a cookie by specifying its name only:-


Q: How we can create the session cookie?

Ans: To create a cookie that lasts only as long as the user is running the browser, pass setcookie() an expiry argument of 0.

setcookie(“session_id”, “8832”,0);

The browser does not remember this cookie after it has been quit or restarted.

Categories: PHP