Login   Register  
PHP Classes
elePHPant
Icontem

Troubled witth Session Cookies

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us

      Cookie Handler Class  >  All threads  >  Troubled witth Session Cookies  >  (Un) Subscribe thread alerts  
Subject:Troubled witth Session Cookies
Summary:How to save cookies when session data is being saved in a DB.
Messages:1
Author:Andy Kay
Date:2008-02-03 02:27:42
 

  1. Troubled witth Session Cookies   Reply  
Picture of Andy Kay
Andy Kay
2008-02-03 02:27:42
Please help me figure out why I can't get cookies set up.

I recently changed my site to use sessions stored in a database. BTW, I'm on a shared server running PHP Version: 4.4.7 and MySQL Version: 5.0.30.

I made the following changes; session.use_cookies: On
session.use_only_cookies: On
session.use_trans_sid: Off

Now. I observed the following.
Firstly, session id is recreated everytime I visit the page which has session_start(). Secondly, the session is only valid in the current page. Subsquent page calls (URLing to another page) cannot see the session variables set earlier.
- For a minute I accepted that I can live with that but then - it's back to the drawing board.

Finally, the main problem. Not Cookies are being created.

I tried:

setcookie("suidone","doh");
echo "ck1:" . $_COOKIE['suidone'];

$lifetime = time() + 1440;
setcookie("suidtwo", session_id(), $lifetime,"/","blessedwithoutlimits.com");
if (isset($suid))
echo "ck2:" . $_COOKIE['suidtwo'];

None of these creates a cookie. (Checked using Firefox, Tools->Show Cookies)

Attempts: I have googled on this for 48+ hours and tried several solution to no avail. Tried .htacess too. session.cookie_path and the like.

Please advise what I might be doing wrongly with the whole thing of saving sessions in a database then use the "one" cookie (preserved sesion id) to ID the user during the session.

I would also appreciate if someone can 'clickpoint' me to the right material/place to find help.

Many thanks in advance.
Drew