taith Posted June 16, 2007 Share Posted June 16, 2007 anyone know a way of getting cookie information right away... like so... <?php setcookie ("testcookie","test value",time()+86400,"/"); echo "Here is our cookie value: <b>".$_COOKIE[testcookie]."</b>"; ?> from what i've seen... php doesnt keep the information, untill the next reload of the page...? Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/ Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 session and cookies i say. look up database sessions ok. Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275761 Share on other sites More sharing options...
Orio Posted June 16, 2007 Share Posted June 16, 2007 That's right- before a php script executes the $_POST, $_GET, $_COOKIE etc' arrays are set and updated. So your script won't work. Orio. Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275762 Share on other sites More sharing options...
taith Posted June 16, 2007 Author Share Posted June 16, 2007 i assume the best way to check if cookies are enabled then... is on the splash page to a site, set cookie, when enters, if cookie not there... error...? Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275770 Share on other sites More sharing options...
Dragen Posted June 16, 2007 Share Posted June 16, 2007 I was looking into this the other day and setting the cookie on the splash page seems the best bet. Then if the user accesses another page without going through the splash page at some point during the session, then it re-directs them to the splash page Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275771 Share on other sites More sharing options...
taith Posted June 16, 2007 Author Share Posted June 16, 2007 but if cookies are disabled in the browser... they'd get sent to the splash page every time they tried to enter the site ... now... if you require cookies... i can see that workin then... you'd need some sort of error on your splash page about cookies then... Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275776 Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 why not use session's that what there for. if you use sssions then it will work properly but as said cookies are browser redundent. Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275779 Share on other sites More sharing options...
Dragen Posted June 16, 2007 Share Posted June 16, 2007 yeah. I guess it depends how important it is that they have that cookie set. If it's not important and only a few users will make use of it by, perhaps visiting a certain page which requires it, then there's no need to require it on every page. But I'm sure you've already considered that Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275780 Share on other sites More sharing options...
taith Posted June 16, 2007 Author Share Posted June 16, 2007 sessions require cookies not to hold the data... but to hold the string that relates to the servers' session file... and their helpful for insignifigant things... like templates... languages... or settings of that source... Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275783 Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 taith session do require cookies but they also can be used via there own source so therefore the browser with cookies off the session will still work that was my point. so in essance session's out way cookies so in this case session should be used. Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275784 Share on other sites More sharing options...
taith Posted June 16, 2007 Author Share Posted June 16, 2007 yes... but thats not the point... i want to use cookies for stuffs... cross browser session stuffs... Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275793 Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 you can also use sessions for that just give the session a critra name example of sessions set but using them while crossbrowsing another page. so the bills might be only shown in the admin page. <?php session_start(); // these are my user sessions. $_SESSION['name']=$name; $_SESSION['age']=$age; $_SESSION['gender']=$gender; // this is my account sessions //even tho i got the bill information in the sessions i will be able to see //or use them on a bill page but at the same time nothink to do with the users sessions //even they are set to be used later. $_SESSION['bill1']=$row['b1']; $_SESSION['bill2']=$row['b2']; $_SESSION['bill3']=$row['b3']; ?> Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275800 Share on other sites More sharing options...
taith Posted June 16, 2007 Author Share Posted June 16, 2007 you misunderstand me... cross browser... not cross page... as in close browser, open browser, settings stay. sessions are extreamly useful! just... not for this... Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275810 Share on other sites More sharing options...
redarrow Posted June 16, 2007 Share Posted June 16, 2007 your WRONG sessions are grate for that you must reed my first post. You can use session with a database and it works perfect for cross web sites . Quote Link to comment https://forums.phpfreaks.com/topic/55826-getting-cookies-immediatly/#findComment-275812 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.