473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Problem with cookies

118 100+
Hi,


my requirement is to "when we close the browser it automatically signout the account". For that i am using the cookies and set the cookie expiration time as '0' . But it didn't work in mozilla and it works fine in IE.
Here is code i am using

Expand|Select|Wrap|Line Numbers
  1.  
  2. <?
  3. if(isset($_POST['submit'])){
  4. $email=$_POST['email'];
  5. $password=$_POST['password'];
  6. setcookie("TestCookies", $email,0);
  7. setcookie("TestCookies1", $password,0);
  8. echo $_COOKIE['TestCookies'];
  9. }
  10. ?>
  11. <html>
  12. <body>
  13. <?
  14. if(isset($_COOKIE['TestCookies'])){
  15. echo "Welcome to ".$_COOKIE['TestCookies'];
  16. echo "<br>";
  17. echo "<a href=logout.php>Logout</a>";
  18. }
  19. else{
  20. ?>
  21. <form name="form1" method="post" action="">
  22. Email: <input type="text" name="email" value="" /><br />
  23. Password: <input type="text" name="password" value=""  /><br />
  24. <input type="submit" name="submit" value="Submit" />
  25. </form>
  26. <?
  27. }
  28. ?>
  29. </body>
  30. </html>
  31.  
  32.  
logout.php

Expand|Select|Wrap|Line Numbers
  1. <?
  2. setcookie('TestCookies',"");
  3. setcookie('TestCookies1',"");
  4. header('Location:login.php');
  5. ?>
  6.  
Any body please give the solution how can i resolve my problem.
please help me.Its urgent.
Mar 31 '09 #1
2 874
Markus
6,050 Expert 4TB
SESSIONS are alive until the browser is closed, or before (depending on the lifetime setting.

http://uk3.php.net/session
Mar 31 '09 #2
Nert
64
Yeah, markus is right, try using SESSION, in PHP settings by default the session is set to end when the browser is closed.

check this out.
http://us3.php.net/manual/en/intro.session.php
Apr 1 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: TJO | last post by:
Can someone at MS please reply to this. I am trying to post data so a web form via ssl with the following code. I keep getting this error: "The underlying connection was closed: Could not...
2
by: Netanel | last post by:
Hi, I have a site that I developed in ASP / VBScript. Some of the visitors are complaining that they can't get in into the system (using the login form of-course). My login form includes...
7
by: patbaudy | last post by:
Hi, I'm coding a shopping cart in asp. I store all info about ordered items, customer's coordonates, etc...into cookies. When the order is complete I use "CDONTS.NewMail" to send an order...
1
by: rushik | last post by:
Dear all, We have created a business portal for our organization. The technology used for that is LAMP. Our major access management system of the portal is based on cookies. we set some user...
0
by: Claudio | last post by:
I have a demo app where cookies does not work. The first page create a cookies. The second read the contet. If I browse the pages via IE6.0 the pages does not work. If I browse the pages via...
12
by: Patxi | last post by:
This is the first time I try to use cookies, and despite of reading some tutotials, I'm have real trouble to make it work correctly. My cookie reading code is in Master Page. When I click on a...
0
by: André | last post by:
Hi, I try to insert a graphic (bitmap) to the first file. No problem any more with that. But the graphic generated in the second file (graf2.aspx) must receive values from the the first file. I...
3
by: lawrence k | last post by:
This site was working: http://www.thesecondroad.org/ Now I'm told people are unable to create new accounts or log in. One theory: It seems that cookies are not being set. Our beta testers...
3
by: jacusp | last post by:
Hi, I have problem with reading cookies. I'd like to save fields of my form into cookies and use them by another page. I save cookies: foreach ($_POST as $idx =$value) { setcookie($idx,...
7
by: cmrchs | last post by:
Hi, In Windows Vista: where does asp.net write its cookies? I use HttpCookie objCookie = new HttpCookie("nameCookie"); in Win2000 (and later) they used to be in C:\Documents and...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.