hi everyone,
i am a newbie in php and facing a problem regarding cookies.
i have following settings in my php.ini file:
session.save_path = "C:\Program Files\Apache Group\Apache2\htdocs\tmp"
session.use_cookies = 1
session.cookie_lifetime = 0
session.cookie_path = "C:\Program Files\Apache Group\Apache2\htdocs\cookies"
session.cookie_domain =
Earlier i had session.cookie_path = / ------default value, i changed it to the above mentioned cookies directory which is mentioned above.
i dont know where is the default value for / session.cookie_lifetime = session.cookie_lifetime = / / pointing towards.
now i am writing following code:
<?php
session_start();
$val = setcookie("test_cookie","hello");
if($Val == TRUE)
echo "cookie set<br>";
else
echo "problem setting cookie";
$cookie_val = $_COOKIE['test_cookie'];
echo $cookie_val;
?>
i get the output cookie set
hello
now when i go to cookie tmp directory according to the:
session.save_path = "C:\Program Files\Apache Group\Apache2\htdocs\tmp" ---- i get the files having names like session ids (sess_20d809b36ece8a6c85ebd706532ddefc) when i double click the file and open with notepad i dont get the value which i had set using the setcookie function (i.e. hello).
plz help me knowing how can i access cookies, where are they stored as i do not get any thing in cookies directory which i created for session.cookie_path setting.
why am i not getting the hello value for cookie in the tmp directory session file.
Thank you
Gaurav
cookie problem
Moderator: General Moderators
-
gaurav_sting
- Forum Newbie
- Posts: 19
- Joined: Sat Mar 27, 2004 3:45 am
- Location: Delhi
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
session.cookie_path shouldn't be a path on the server.. it's the stored inside the cookie for usage by the browser. It was '/' for a reason.
You can't retrieve the cookie's value as the cookie isn't available under the location of the php file. Try changing the session.cookie_path back to the original default of /
You can't retrieve the cookie's value as the cookie isn't available under the location of the php file. Try changing the session.cookie_path back to the original default of /