Jump to content

getting cookies immediatly


taith

Recommended Posts

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...?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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 ;)

Link to comment
Share on other sites

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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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'];

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.