Hello im using a cookies script But i need a simple code that goes up the top of the page how to Like <script> AddCookie ('cookie.filename') </script> i have no clue if its possible or if you need MYSQL any help with this one pls
Printable View
Hello im using a cookies script But i need a simple code that goes up the top of the page how to Like <script> AddCookie ('cookie.filename') </script> i have no clue if its possible or if you need MYSQL any help with this one pls
So you want to give a user a cookie yeh?
Use sessions, they're safer. One little 'problem' is that when you close the browser they're destroyed.
But this is how you use them...
I don't know about cookies, much, as I never use them.PHP Code:session_start(); // allowing you to start sessions
$_SESSIONS['whatever'] = "Whatever is in the session, a username or whatever"; // makes the session
session_destroy(); // destroys the session
To set a cookie using Javascript use a function like this:
But seriously, ******* Google it next time :\HTML Code:<script type="javascript">
<!--
function SetCookie(cookieName,cookieValue,nDays) {
var today = new Date();
var expire = new Date();
if (nDays==null || nDays==0) nDays=1;
expire.setTime(today.getTime() + 3600000*24*nDays);
document.cookie = cookieName+"="+escape(cookieValue)
+ ";expires="+expire.toGMTString();
}
//-->
</script>
or in php..
PHP Code:<?php
ob_start();
setcookie("Cookie Name","Cookie Value",time()+3600);
?>
You seriously need to learn how to spell and speak before posting again, it is driving me crazy.
Edited by Agesilaus (Forum Super Moderator): Please do not post off topic.