Toggle navigation
Bootsnipp
Bootstrap
For
CSS Frameworks
Bootstrap
Foundation
Semantic UI
Materialize
Pure
Bulma
References
CSS Reference
Tools
Community
Page Builder
Form Builder
Button Builder
Icon Search
Dan's Tools
Diff / Merge
Color Picker
Keyword Tool
Web Fonts
.htaccess Generator
Favicon Generator
Site Speed Test
Snippets
Featured
Tags
By Bootstrap Version
4.1.1
4.0.0
3.3.0
3.2.0
3.1.0
3.0.3
3.0.1
3.0.0
2.3.2
Register
Login
"coookie"
Bootstrap 3.1.0 Snippet by
muhittinbudak
3.1.0
Preview
HTML
View Full Screen
Fork
Fork this
0
 
0 Fav
Post to Facebook
Tweet this
<link href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.0/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html lang="tr"> <head> <meta charset="UTF-8"> <title>jQuery Cookie Örnek</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css"> </head> <body> <div class="container" style="margin-top:30px;"> <h3>jQuery Cookie Örnek</h3> <div class="form-group"> <label>Cookie Değeri Giriniz</label> <input type="text" id="cookieValue" class="form-control input-lg" placeholder="örnek: merhaba"> </div> <button id="btnSet" class="btn btn-success btn-block">Cookie Oluştur / Set Et</button> <button id="btnGet" class="btn btn-info btn-block">Cookie Değerini Getir / Oku</button> <button id="btnDelete" class="btn btn-danger btn-block">Cookie Sil / Destroy</button> <hr> <div id="alertArea"></div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script> <script> $(document).ready(function(){ var cerez = $.cookie('cerezDeneme'); if (typeof cerez === 'undefined' || cerez === "" || cerez == 0) { $("h3").text("boş"); } else { $("h3").text("dolu"); } // ———————————————————————————— // Cookie Set (Atama) // ———————————————————————————— $("#btnSet").click(function(){ var val = $("#cookieValue").val(); $.cookie("cerezDeneme", val, { expires: 7, // 7 gün boyunca cookie saklanır path: "/" // tüm sitede geçerli }); $("#alertArea").html( '<div class="alert alert-success">Cookie <strong>cerezDeneme</strong> oluşturuldu! Değer: ' + val + '</div>' ); }); // ———————————————————————————— // Cookie Get (Çalma / Okuma) // ———————————————————————————— $("#btnGet").click(function(){ var cookieVal = $.cookie("cerezDeneme"); if (cookieVal !== undefined) { $("#alertArea").html( '<div class="alert alert-info">Cookie <strong>cerezDeneme</strong> değeri: ' + cookieVal + '</div>' ); } else { $("#alertArea").html( '<div class="alert alert-warning">Cookie <strong>cerezDeneme</strong> bulunamadı!</div>' ); } }); // ———————————————————————————— // Cookie Delete / Destroy (Silme) // ———————————————————————————— $("#btnDelete").click(function(){ $.removeCookie("cerezDeneme", { path: "/" }); $("#alertArea").html( '<div class="alert alert-danger">Cookie <strong>cerezDeneme</strong> silindi!</div>' ); }); }); </script> </body> </html>
Questions / Comments:
Post
Posting Guidelines
Formatting
- Now
×
Close
Donate
BTC: 12JxYMYi6Vt3mx3hcmP3B2oyFiCSF3FhYT
ETH: 0xCD715b2E3549c54A40e6ecAaFeB82138148a6c76