/    Sign up×
Community /Pin to ProfileBookmark

setcookie($name, $value, $expires, $this->path, $this->domain, $this->secure);

[code=php]<?php

class cookie
{

var $path=”/”;
var $domain=”localhost”;
var $secure=0;

function sc($name, $value)
{
$expires = time()+3600;
setcookie($name, $value, $expires, $this->path, $this->domain, $this->secure);
}

}
?>[/code]

[code=php]<?php
include_once(“obj/class.cookie.php”);
$ck=new cookie();
$ck->sc(“servers”,”asdasdasdasd”);
print_r($_COOKIE);
?>[/code]

ok why this not working 😑

to post a comment
PHP

6 Comments(s) ↴

Copy linkTweet thisAlerts:
@WebnerdFeb 15.2006 β€”Β Try

[code=php]
<?php
include_once("obj/class.cookie.php");
$ck=new cookie();
$ck->sc("servers","asdasdasdasd");
flush();
print_r($_COOKIE);
?>
[/code]
Copy linkTweet thisAlerts:
@bokehFeb 15.2006 β€”Β Because you cannot set and then read a cookie on the same iteration of the script.

Also I just cant see any benefit from this class at all. It seems to me to be extra code just for the hell of it.
Copy linkTweet thisAlerts:
@SpectreReturnsFeb 16.2006 β€”Β To be fair, my first class was one which checked to see if emails were valid.
Copy linkTweet thisAlerts:
@gert_cuykensauthorFeb 16.2006 β€”Β no flush or refreshing the page doesnt work :mad:

this works doh ?

[code=php]if ($_GET['set'] != 'yes') {

setcookie ('test', 'test', time() + 60);

header ("Location: cookietest.php?set=yes");

} else {

if (!empty($_COOKIE['test'])) {

echo "Cookies are enabled on your browser";

} else {

echo "Cookies are <b>not</b> enabled on your browser";

}

}[/code]


I think i will just use the simplified version PS when i https the cookie page wil the cookie be sent encrypted automaticly or do i need to specify the security parameter to 1 seperatly ?

The reason i put it in a class is i finaly understand how it works and now i put everything in classes ?
Copy linkTweet thisAlerts:
@bokehFeb 16.2006 β€”Β The sixth argument just tells the browser whether (value [I]0[/I]) it may be sent over any type of connection or (value [I]1[/I]) it may only be sent over a secure (SSL) connection. Left unspecified it defaults to value [I]0[/I]. Value [I]1[/I] does not tell the browser to encrypt the cookie, it just tells it, it may not be sent over an unsecured connection. Anything that passes between the browser and the server over an SSL connection (including cookies, query strings and post requests) is encrypted anyway.
Copy linkTweet thisAlerts:
@gert_cuykensauthorFeb 16.2006 β€”Β ok thx
Γ—

Success!

Help @gert_cuykens spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 β€” BETA 5.5,
whats_new: community page,
up_next: more Davinciβ€’003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinciβ€’003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...