Jump to content

Recommended Posts

How do I save or what is the syntax  to save a button in a cookie?  test site    test  I did try a header like <h3>Hello</h3> but get error with a boot5 button.

 

<code>

<?php

 $mp = "vids/coli.mp4";
  $dall ="aaa";// echo "dall=".$dall;
  $uep = `<button type="button" class="btn btn-warning" onmouseover="show(0)" onmouseout="hide(0)" onclick="skip(-5000) ">0:0:0</button>`; //echo "uep=".$uep;
   
     
    
 
     setcookie('mp'.'$mp'.time()+30*24*60*60.);
 setcookie('dall'.'$dall'.time()+30*24*60*60.);
   setcookie('uep'.'$uep'.time()+30*24*60*60.);
?>

</code>

 

?

Edited by requinix
removing unnecessary verticality
Link to comment
https://forums.phpfreaks.com/topic/316251-buttons-and-cookies/
Share on other sites

It's a long story but if you go to this site in development, you will get a better idea what I am trying to do. It is a system to build like a 'TOC' or entry ponits  on the video . The buttons when clicked goto whatever cuttennt-vid-time you have set. It is for video presentations and other things.  Go into the video and click the new ep button, You will get a popup explaining the operation, When done I want to savethe src of the video,  comments for the entry points and the buttons added in cookies  Use the red EP button as return after  playing the video a few seconds and adj to desired EP

 

Video site 

The actual php (reached by ajax) to set cookies 

<code>

<?php
session_start();
if(isset($_POST["mp"])){   // echo "set";
 
  $mp = $_POST["mp"];
  $dall = $_POST["dall"];// echo "dall=".$dall;
  $uep = $_POST["uep"]; //echo "uep=".$uep;
   
     $_SESSION["mp"] = $mp;
    $_SESSION["dall"] = $dall; echo "sesdall".$_SESSION["dall"];
    $_SESSION["uep"] =  $uep;  echo "sesuep".$_SESSION["uep"];
    
 
     setcookie('mpCookie'.'$mp'.time()+30*24*60*60.);
 setcookie('dallCookie'.'$dall'.time()+30*24*60*60.);
   setcookie('uepCookie'.'$uep'.time()+30*24*60*60.);    

</code>
 
   

 
}
?>

Edited by cabbie
Link to comment
https://forums.phpfreaks.com/topic/316251-buttons-and-cookies/#findComment-1608014
Share on other sites

Still not following, and I can't go through your site at the moment, but:

It typically doesn't make sense to put values into both the session and cookies. One of them is enough: put the values in the session if you want to remember it for the user account (kinda), or put the values in cookies if you want to remember it for the device they're browsing with.
And if you choose to use cookies only, you don't even need AJAX - you can create cookies perfectly fine with Javascript.

So, then, I guess, general troubleshooting: Can you see that the AJAX request is being POSTed correctly with the right data? Does your browser show the cookies updating values, or at the very least expiration times?

Link to comment
https://forums.phpfreaks.com/topic/316251-buttons-and-cookies/#findComment-1608018
Share on other sites

  • 2 weeks later...

Yes.  Is this still an open topic?  Usually people let us know when they are done with it.  Although I would love to know what you mean by 'saving' a button?  A button is simply some code so how would one do that and then use a 'saved button'?

Link to comment
https://forums.phpfreaks.com/topic/316251-buttons-and-cookies/#findComment-1608399
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.