Current location: Hot Scripts Forums » Programming Languages » PHP » PHP and Cookies


PHP and Cookies

Reply
  #1 (permalink)  
Old 07-03-04, 06:03 AM
Christoff Christoff is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Angry PHP and Cookies

Hi there!

I've got a script, where I read data from a cookie via PHP into a javascript array and on page unload I set a new cookie value via javascript.

Now the thing is, I have to refresh the page before I redirect, why cant I set the cookie on unload? why do I HAVE to refresh the whole page, before I redirect to set the new Value...
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 07-03-04, 12:01 PM
Eclipse's Avatar
Eclipse Eclipse is offline
Coding Addict
 
Join Date: May 2004
Location: Long Island, New York
Posts: 356
Thanks: 0
Thanked 0 Times in 0 Posts
could you maybe post the code or a snippet that would be helpful.
peace,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #3 (permalink)  
Old 07-03-04, 12:46 PM
Christoff Christoff is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Unhappy Code

This is the function that loads during "onUnload".

function einde ()
{
inisiasie=sele.join(",");
inisiasie=strreplace(inisiasie,",,",",");

if (inisiasie.charAt(0)==",") inisiasie=inisiasie.substring(1,(inisiasie.length) );
if (inisiasie.charAt(inisiasie.length)==",") inisiasie=inisiasie.substring(0,(inisiasie.length-1));

SetCookie("temp_array",inisiasie);

}

But for some reason a simply redirect doesnt change the cookie value, which is should, cause the page runs the function on page unload. First Refresh and then redirect
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #4 (permalink)  
Old 07-03-04, 12:47 PM
Christoff Christoff is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
functions

Setcookie is a function that sets the cookie
and strreplace is a REAL string replace function that actually works.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #5 (permalink)  
Old 07-03-04, 05:05 PM
Christoff Christoff is offline
Newbie Coder
 
Join Date: Jun 2004
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Nevermind

Its all thanks to PHP's output buffering system, thats why things arent updating of redirecting, so ya, that can probably be fixed....
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with PHP cookies robii1 PHP 4 05-18-04 05:00 PM
Accepting Bids for Mambo/Other Scripts Integration Projects spcover Job Offers & Assistance 0 04-28-04 10:30 AM
Quick Question for you php guru's Tokahashi PHP 3 04-09-04 01:00 PM
Help with getting PHP coded software to Work with IIS 6 Tekki Job Offers & Assistance 2 11-20-03 02:30 PM
php guestbook standarddeviant Job Offers & Assistance 3 11-20-03 08:13 AM


All times are GMT -5. The time now is 09:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.