Oplus99 Posted July 20, 2011 Share Posted July 20, 2011 Hi,I need to know where I can modify some codes or cookie stuff when a user close his browser the cookies are destroyed.I don't want the user to get back to the store without logging in.thank you, Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 20, 2011 Share Posted July 20, 2011 Setting cookie expiry is relatively straight forward. I don't really know where the cookie is defined, but chances are somewhere in the file tree there is a class file or plain included file called cookie.php Here is the information from the php manual about setting a cookie to expire on browser close: http://us.php.net/setcookieBasically what you have to do is set the cookie expiry to 0 which will disable it once the browser is closed. Link to comment Share on other sites More sharing options...
Oplus99 Posted July 20, 2011 Author Share Posted July 20, 2011 thanks for your reply, I know all about setting the cookie to 0. But my problem is where to put it. and how I can access the cookie variable. Link to comment Share on other sites More sharing options...
Lindsayanng Posted July 20, 2011 Share Posted July 20, 2011 I dont know prestashop good enough but like i said, chances are there is a file named COOKIE.php so do a search for that file name and see what pops up. Once you get in there you will be able to find that excerpt of code easily. Usually the cookie info is in it's own page and just included in something like application_top which you will NOT find the variable Link to comment Share on other sites More sharing options...
Niriza Posted September 1, 2011 Share Posted September 1, 2011 I also want the cookie to be cleared when the browser is closed. Did anyone find the solution until now? If anyone have done this please do share the solution. Thanx Link to comment Share on other sites More sharing options...
allienato Posted October 31, 2011 Share Posted October 31, 2011 I'm able to clear cookies when the browser is closed, but it won't always works. Basically, I use a javascript function to detect if the user close his browser and, if positive, I make an ajax call to the index page, passing the logout parameter (it's the same path used by logout link/button). function fnUnloadHandler() { xmlhttp=null; if (window.XMLHttpRequest) {// code for Firefox, Opera, IE7, etc. xmlhttp=new XMLHttpRequest(); } else if (window.ActiveXObject) {// code for IE6, IE5 xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); } if (xmlhttp!=null) { xmlhttp.open("GET","http://www.yourprestashopsite.com/index.php?logout",true); xmlhttp.send(null); } else { alert("Your browser does not support XMLHTTP."); } } problems with this approach: - Javascript must be turned on (minor problem nowadays) - since it should works when you close the browser, it won't work when you close only the browser's tab note: I've added some code in the cookie logout function (classes/Cookie.php) in order to launch sql commands when the function is called. It works even when the tab is closed, while cookies aren't deleted. Link to comment Share on other sites More sharing options...
lonasito Posted December 4, 2013 Share Posted December 4, 2013 Hi allienato, is there a chance you could share the modified Cookie.php code please? The JS function doesn't seem to be working. Link to comment Share on other sites More sharing options...
Recommended Posts